Geometry Modeling - Snapping to Endpoints in Python API ?
-
Hello,
I'm trying to create circles with gaps for capacitors or sources, and then connect the endpoints across the gaps for the actual capacitors/sources.
Right now I'm creating circles, taking a boolean subtraction of a star-shaped object to cut the gaps, but how can I join the endpoints with new line segments or arcs so that I ensure continuity?
Is there any access to snapping in the Python API?
Actually, maybe taking the intersection with the gap-cutter object would work, instead of subtracting... but very open to other ideas too!
There are many sources/gaps so an automated way in Python would be ideal!
Thank you!
Doug
-
-
Update: taking the intersection did not work, I assume because the circle is curved, and I get this error:
Error : Failed to update waveguide boundaries for BCR (R Middle Src) : Could not deduce the geometry of model BCR
Error : Unable to assign 'BCR' as a Waveguide Source in simulation 'EM'.
So I need a way to find the endpoints of the arcs/gaps so I can draw a straight line there instead (preferably with Python).
Thank you!
-
Hi @dbsim4
I think it would help a lot if you could post an image depicting what you are trying to achieve.Answering the question from the subject line: No, there is no snapping in Python (not sure how that API could look like), but there are functions to get the distance between entities (and corresponding closest points), which may help.
brick1 = XCoreModeling.CreateSolidBlock(Vec3(0), Vec3(1)) brick2 = XCoreModeling.CreateSolidBlock(Vec3(2), Vec3(3)) res = XCoreModeling.GetEntityEntityDistance(brick1, brick2) print(f"Distance brick1-brick2: {res[0].Distance}") print(f"Closest point on brick1: {res[0].ClosestPosition}") print(f"Closest point on brick2: {res[1].ClosestPosition}")
or distance to a point:
brick = XCoreModeling.CreateSolidBlock(Vec3(0), Vec3(1)) res = XCoreModeling.GetEntityEntityDistance(brick, Vec3(3)) print(f"Distance brick-point: {res.Distance}") print(f"Closest point on brick: {res.ClosestPosition}")
For geometry that has end-points or corners, you could extract the vertices and again use distance wrt some other point as a way to write a script.
edge = XCoreModeling.CreateEdge(Vec3(0), Vec3(1)) vertices = XCoreModeling.GetVertices(edge) assert len(vertices) == 2 for v in vertices: print(v.Position) brick = XCoreModeling.CreateSolidBlock(Vec3(0), Vec3(1)) vertices = XCoreModeling.GetVertices(edge) assert len(vertices) == 8
-