Ruby dimensions


#1

Help How do I make size dimensions attach to a group in ruby.
I can create the linear dimensions but if i move the group the dimension do not move with it.


#2

Add the dimension objects to the group’s entities collection.


#3

In normal use dimensions do not have to be inside of a group to move with it. And it is often not desirable that they are contained within the group.
A dimension might connect one vertex in one group with a vertex in a different group. Move one group and the dimension stretches.
I haven’t tried connecting dimensions to groups in ruby but I suspect the key is to have the dimensions connect to the group’s actual vertices. ie: don’t create new vertices for the dimensions.
The same applies to edges.

So I suggest you create a group manually in Sketchup, and add a dimension connected to it.
Then select the dimension and see what vertices it uses.
Select the group and query its vertices.


#4

Hi Barry. Thanks for the reply. You are correct I am not trying to connect
inside the group but outside. I query both it vertices but not managing yet
to get them to connect and stretch and move with the group.
So any further Ideas are welcome. Thanks again


#5

Look at the API documentation for Entities.add_dimension_linear
There are several options for defining the start and end. You need to specify the vertex within the group NOT a point3D.

Be aware also that the API has no way for you to set the text characteristics (font, size, etc.) for dimensions.
As far as I am aware, you are only the second person who has tried to add dimensions within an extension. Mine is 2DXY SiteSurvey: see: https://youtu.be/7M3B6Mu22NM


#6

Hi,
This is currently a limitation in the Ruby dimensions API. You do have to place the dimension inside the group’s entities. Even if the dimension is attached to a vertex of the group, (and the dimension is outside the group), SketchUp will not know which instance of the vertex the dimension is supposed to follow. This is because the API doesn’t provide a way to specify an instance path. Sorry :frowning:

Bugra


#7

Hi Barry
Thanks for this. I watched your video very interesting, Good work.
Looks like it cannot be done according to Burga, see his comment.
Kimberley


#8

Thanks Dan for the heads up.
Tried this but did not work yet. still coding away.
Will have a cool quick dimensioning plugin very soon
Kimberley


#9

Hi Burga
Can you put in a feature request for this option for us. We have made a really cool auto dimensioning plugin and it would be nice if we can mimic the native dimension tool where dimensions stick to a group or components vertices when moved or scaled.
many thanks for your quick response, saved us hours trying to do something that cannot be done.
are you 100% this cannot be done at moment
kimberley


#10

Hi Kimberley,
I logged this issue in our system. I agree, it’s a pretty big limitation and we’ll fix it.
Thank you!


#11

It’s been a year. Has any progress been made on this? I’ve been experimenting again, and it still seems I can attach a dimension end point to the model, and have it “stick”.


#12

But with the SketchUp 2017 release 4 months later (than the comment above,) a new class was introduced to get instance paths, but it may not have yet been “wired into” the dimension factory methods of the Entities class.


#13

Hi Bugra

Any progress on API ref Dimensions sticking to groups using ruby???
We want to develop plugin further .

Kim

bugra http://forums.sketchup.com/users/bugra SketchUp Team Member
July 13

Hi Kimberley,
I logged this issue in our system. I agree, it’s a pretty big limitation
and we’ll fix it.
Thank you!


#14

My comment above indicates that there is some progress toward the goal. :roll_eyes:


#15

@daiku
EDIT: The referenced post has been relocated to prevent duplication in conformance with Forum Guidelines.
https://forums.sketchup.com/t/dimension-linear-how-to-make-it-stick-to-geometry-like-when-created-with-the-ui/51306

When I create a linear dimension with the UI, the endpoints “stick” to the geometry to which they are attached. So if I move the thing one end of the dimension is attached to, the dimension stretches. I can’t make this work programmatically with the API however. The dimension object is not attached to anything. So it I move the geometry, the dimension gets left behind.

Also, the dimensions you can make with the UI can show the X, Y, or Z distance between two points. But with the API, the distance is always the absolute distance between the points. I can’t get the same behavior as with the UI.

I’ve read elsewhere on this forum that it’s a limitation in the API. Has anyone else gotten it to work? Or does the Sketchup Team have plans to fix this?


#16

Hi Daiku
I am not sure what the sketch-up team do. I was hoping for a fix or a
solution by now, so it must not be important to them at the moment.
Hopefully they will add better control over dimension attribute soon in the
API, it is holding us back from developing the auto magic dimensions plugin.
We would like also to add it to Lay-out. Every other CAD program I have
tried uses auto dimensions so hopefully the team will add this feature
themselves or give us the ability to do so.
I cannot understand how the native tool can have the dimension stick but
you cannot do the same in Ruby. and have the dimensions offset from the
group. keep your fingers crossed for the next version.


#17

Agreed. I started working on an “auto-dimension” feature for my plugin when the dimension_linear component first appeared a few years ago, but had to abandon the effort due to these limitations. I’d be happy to beta-test any WIP the SU team wants to take for a spin. CB.


#18

Again, I quote @bugra above: