Clipping When drawing from a Tool
-
When drawing temporary geometry from a Tool, the geometry often gets clipped. There is a tool.getExtents method which sounds like exactly what I need to fix this.
From the docs:
@unknownuser said:
In a typical implementation, you will create a new BoundingBox, add points to set the extents of the drawing that the tool will do and then return it.
But, how can I get the size of the BoundingBox?
-
See http://download.sketchup.com/sketchuphelp/gsu6_ruby/Docs/Ruby-BoundingBox.html#new
Make a new bounding box - 'new', then 'add' a min point and a max point to it that are well away from where you are at, and you are then drawing geometry within the bbox...
You could dynamically add points to the bbox as you move your cursor to ensure that you are still within the bbox ?
If you don't make abbox that's the size of your geometry you can get weird things with groups etc. In the past I have drawn a long diagonal line, which makes the bounds increase and then erased it later BUT the 'add' a point method works...
-
Thanks TIG,
I still don't know how to calculate how big to make the bounding box. Maybe I can use the camera distance to origin as an estimate...
-
@jim said:
Thanks TIG,
I still don't know how to calculate how big to make the bounding box. Maybe I can use the camera distance to origin as an estimate...
Why not get the model's bounding box and x10(0)(00) its min and max ? IF you know how big you are making the geometry then you should be able to make a point equal to where you are defining (or picking) and that'd enlarge the bounding box to suit ?
-
Oh, I see, but I am starting with a blank model - there is nothing to add to the bbox.
-
@jim said:
Oh, I see, but I am starting with a blank model - there is nothing to add to the bbox.
Then make the temporary bbox far bigger than you'd ever expect the drawn geometry to be ?
Clear the temp bbox at the end and the model's bbox then becomes the bbox of the geometry you just made ?
-
If the drawing is getting clipped, it's because you have drawn geometry to get clipped (In other words, you have drawn Geometry, and it is getting clipped).
Since you have thus have physical geometry to work with, you can dump all the points from entities the comprise your drawn geometry into a temporary bounding box, just like TIG suggested. You can then use this temporary bbox to pass to tool.getExtents.
Todd
-
@unknownuser said:
If the drawing is getting clipped, it's because you have drawn geometry to get clipped (In other words, you have drawn Geometry, and it is getting clipped).
Since you have thus have physical geometry to work with, you can dump all the points from entities the comprise your drawn geometry into a temporary bounding box, just like TIG suggested. You can then use this temporary bbox to pass to tool.getExtents.
Todd
It's the lines drawn from within the tool (view.draw) that are getting clipped, not any user-drawn geometry. In this case, there is not yet geometry to add to a BoundingBox.
-
Not a problem. Just use the view points then.
-
The thing with a Bounding Box is - it's virtual. You don't have to have any geometry to create and populate a bounding box.
Advertisement