api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

Entities.add_dimension_linear is incomplete

Open clarkbremer opened this issue 5 years ago • 8 comments

Not sure if this is a bug or a feature request. You recently added the feature add_dimension_linear, which was purported to be able to do anything with a dimension that could be done with the UI. This turned out not to be the case. I would like to have the ability to show the dimension in only one of the three cardinal directions. For example, the distance between two point parallel to the x axis, even of the two points do not have the same y or z coordinate. A picture better describes what I mean. I've attached a code snippet, and a sketch produced by the code snippet. I then edited the sketch to show a linear dimension added using the UI.

  1. SketchUp/LayOut Version: 2019
  2. OS Platform: Mac and Win
mm = Sketchup.active_model
g1 = mm.entities.add_group
pts = [
  [0, 0, 0],
  [10, 0, 0],
  [10, 12, 0],
  [0, 12, 0]
]
face1 = g1.entities.add_face(pts)
face1.pushpull(-8)
c1 = g1.to_component

c2 = mm.entities.add_instance(c1.definition, Geom::Transformation.new([20,30,10]))

v1 = c1.definition.entities.grep(Sketchup::Face).first.vertices.first
puts "vertex 1: #{v1.inspect}: #{v1.position}"
path1 = Sketchup::InstancePath.new([c1, v1])
point1 = v1.position
point1.transform! c1.transformation
puts "point1: #{point1}"

v2 = c2.definition.entities.grep(Sketchup::Face).first.vertices.first
puts "vertex 2: #{v2.inspect}: #{v2.position}"
path2 = Sketchup::InstancePath.new([c2, v2])
point2 = v2.position
point2.transform! c2.transformation
puts "point2: #{point2}"

mm.active_entities.add_dimension_linear([path1, point1], [path2, point2], [0, 0, -30])

linear_dimension_issue

clarkbremer avatar Nov 26 '19 20:11 clarkbremer

Is anyone actively working on this? I'd be happy to test drive experimental code. CB.

clarkbremer avatar Apr 30 '20 00:04 clarkbremer

It hasn't been actively worked on, no. But it's on out list, and parity issues typically get higher priority. I however cannot promise on any timeline.

thomthom avatar May 07 '20 09:05 thomthom

Logged as: SU-47035

sketchupbot avatar Aug 28 '20 11:08 sketchupbot

Just wanted to bump this issue. Would love to see this in SU23.
Related, is there a way to accomplish this with layout ruby api?

clarkbremer avatar Mar 23 '22 19:03 clarkbremer

I guess it's been over a year, so I'll bump this again.

clarkbremer avatar Aug 29 '23 15:08 clarkbremer

Can you think up a way logically to do what the UI can do (create a non-aligned dimension) ? Ie, how would we describe to the API the way to define the kind of dimension you are requesting?

DanRathbun avatar Aug 29 '23 16:08 DanRathbun

The UI just likes to snap to the cardinal planes. A DimensionLinear has a plane method. But there's no plane=.

d
=> #<Sketchup::DimensionLinear:0x000001d811755608>
d.plane
=> [0.0, 1.0, 0.0, -168.00000000003607]

Edit: I have to retract that. The plane method returns the same, whether it's aligned or not.

clarkbremer avatar Aug 29 '23 16:08 clarkbremer

@clarkbremer Edit: I have to retract that. The plane method returns the same, whether it's aligned or not.

Oh, I see that it is inherited from the Dimension superclass. It's documentation does not really explain what the plane of a dimension represents. But we might assume that it was originally meant that the dimension and extension lines, as well as the offset vector, lie upon this plane.

If this assumption is incorrect, then maybe this is a bug when applied to non-aligned dimensions?

I can see that perhaps if we could specific a plane which did not include the start or end point, then the extension line(s) could be multisegmented as shown in your image above. But would this make the offset vector invalid as it assumes that the dimension line will be parallel to the reference line (between the start and end points) ?

DanRathbun avatar Aug 30 '23 11:08 DanRathbun