Check for Empty Space

Check for Empty Space

Anonymous
Not applicable
1,002 Views
5 Replies
Message 1 of 6

Check for Empty Space

Anonymous
Not applicable

Hello, I am wondering if there is a way to check whether an X, Y, Z point in the active document is empty or not, and if it is not, how to check whether it is a sketch, a plane, an extrusion...etc.

0 Likes
Accepted solutions (1)
1,003 Views
5 Replies
Replies (5)
Message 2 of 6

ekinsb
Alumni
Alumni

The only thing that's somewhat like this in the API is that for a known solid body you can determine if a point is inside, outside, or on the body.  You use the BRepBody.pointContainment method.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 6

Anonymous
Not applicable
Accepted solution

So there's no way to check whether a point (x, y, z) is inside a sketch, a solid body or nothing?

0 Likes
Message 4 of 6

ekinsb
Alumni
Alumni

I'm not really sure what it would mean for a point to be inside a sketch.  Do you mean that it lies anywhere on the X-Y plane of the sketch?  A sketch is 3D so technically anywhere in the model could be in the sketch.  For BRepBody objects there is a function I forgot to mention in my previous post.  The Component object supports the findBRepUsingPoint method so that given a point in space it will return the BRepBody the point is on.  However, in this case the point must be on one the body and can't be inside.  There is also another method supported by the Component called findBRepUsingRay that let's you specify a point and direction (vector) in space and it will return all of the bodies intersected by the ray.

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 5 of 6

Anonymous
Not applicable

Yes, anywhere in the XY plane of the sketch. For what I'm trying to do, is write a python script that sketches a line that goes around another sketch, but I don't know the dimensions of this sketch. 
For instance, I have the following below. I want to create a python script that draws a line that connects one edge of the first square, to the edge of the second square, without knowing the dimensions of the squares. So in that case, I have to do a pathfinding algorithm to find the best path to draw these lines without colliding to another sketch. That's why I wanted to see if there was a way to check if a XY or XYZ point on a  plane was inside a sketch, body,...etc.




 fusion360.jpg

0 Likes
Message 6 of 6

ekinsb
Alumni
Alumni

I think what you really want is to know the bounding box that the sketch occupies.  The Sketch object supports the boundingBox property that returns the outer limits of the sketch in model space.  I think you might want to get the bounds of the sketch with respect to sketch space.  To do that you'll need to iterative over all of the sketch curves in a particular sketch and combine the bounding boxes from each curve.  I recently created a blog post discussing bounding boxes that might help.  It's not about sketches but the concepts are the same.

 

http://modthemachine.typepad.com/my_weblog/2017/06/getting-the-overall-size-of-parts.html


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes