Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. Geometry Modeling - Snapping to Endpoints in Python API ?

Geometry Modeling - Snapping to Endpoints in Python API ?

Scheduled Pinned Locked Moved Solved Python API
python
3 Posts 2 Posters 515 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dbsim4
    wrote on last edited by dbsim4
    #1

    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

    1 Reply Last reply
    0
    • D dbsim4 marked this topic as a question on
    • D Offline
      D Offline
      dbsim4
      wrote on last edited by dbsim4
      #2

      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!

      brynB 1 Reply Last reply
      0
      • D dbsim4

        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!

        brynB Offline
        brynB Offline
        bryn
        ZMT
        wrote on last edited by
        #3

        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
        
        1 Reply Last reply
        1
        • SylvainS Sylvain has marked this topic as solved on
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Search