How the RUBY apply a dimension(with label, dimension line wi
-
May I know that how the RUBY apply a dimension(with label, dimension line with arrow end) to a line or edge, please?
Thanks
Oscar -
It can't, AFAIK At least V5 can't.
Don't know with V6, some topics here are about dims being added to geometry so I suppose it is possible. Did you found nothing helpful in the Ruby docs ? -
Hi, Didier Bur
Thanks for your reply!
May I know how to select the end point or mid point with the mouse indicator select via RUBY, please? Just like the indicator appear when the mouse near the end or mid point of an edge.Thanks
Oscar -
Hi,
When implementing a tool class, the pick method called for an InputPoint object should do the trick itself:
For instance:def activate @ip1 = Sketchup;;InputPoint.new ... end def onLButtonDown_old(flags, x, y, view) @ip1.pick view, x, y ...
Look at the example "linetool.rb" which comes with SU.
Hope this helps, -
To confirm, dimensions are unaccessible through ruby, C++, fortran, or anything else, for any version of SketchUp (through v6 at least).
It's been requested, so we'll see what happens...
-
There is a trick that could do this...
I'll use 'metres' in the example below but you can adjust this to suit whatever units you want...
Make a 1m long dimension (X) against a horizontal edge - in a 'flat' XY orientation, with a 1m long leader offset (Y).
Highlight the dim and make it into a component - called let's say 'Dim'.
Save it externally as its own 'skp' - into a logical folder path.
In a model, your script then inserts an instance of Dim.skp from the folder.
In your model/script you have the required edge...
The edge has a knowable length (let's say 2.1m), so your script transform scales the instance proportionately by x2.1 in X.
The figured dimension will automatically adjust to 2.1m to suit.
You can also adjust the leader scale (Y).
Transform the instance location and rotation to suit the edge's.
You now have a dimension that reflects the edge's length and orientation. You can also use this method to script a 'dimension' between any two known points...You might also be able to change the 'orphaned dim' colour to match the normal dim's colour ? Not sure how to access/set this ???
The dim's arrow heads will scale in the X... too so you might want to make a set of Dim skps - say 1-100mm, 100mm-1m, 1m-3m, 3m-10m etc and then insert instances of them to match nearest to the edge's length - so that the subsequent scaling of them wouldn't distort the dim-compo's arrow heads too much...
You could also 'connect' the edge and component-dim using attributes and observers, so if the particular edge changed, then the associated dim-compo could be adjusted automatically to suit... It would then behave very much like a normal associated dimension.
This could be all very convoluted to achieve, BUT it's still possible...
Advertisement