api-issue-tracker
api-issue-tracker copied to clipboard
Entities.add_dimension_linear is incomplete
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.
- SketchUp/LayOut Version: 2019
- 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])
Is anyone actively working on this? I'd be happy to test drive experimental code. CB.
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.
Logged as: SU-47035
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?
I guess it's been over a year, so I'll bump this again.
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?
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 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) ?