Virtual Topology [Split Edge at +]

Akane Ito
Akane Ito Member Posts: 38
10 Comments 5 Likes Name Dropper
**
edited July 2024 in Structures

Please tell me how to "Split Edge at +" .
And, can it be done at an arbitrary point (coordinate) instead of at +?

Answers

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 327
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited July 2024
    edgeID = 18
    split_ratio = 0.25
    
    selection=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
    selection.Ids = [edgeID]
    
    try: virtual_topology = ExtAPI.DataModel.Project.Model.AddVirtualTopology()
    except: virtual_topology = ExtAPI.DataModel.GetObjectsByType(Ansys.ACT.Automation.Mechanical.VirtualTopology)[0]
    
    virtual_topology.VirtualSplitEdge(selection,split_ratio)
    
  • Akane Ito
    Akane Ito Member Posts: 38
    10 Comments 5 Likes Name Dropper
    **

    @Landon Mitchell Kanner
    Thank you!
    Can it be done with a point, not ratio?"

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee, GitHub-issue-creator Posts: 327
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited July 2024

    I don't see any direct method. I think you would have to write your own code to calculate the ratio. There are some functions in the attached SolidMechanics.py file that can help. Here is something crude (assumes straight edge and units are consistent; have not thoroughly tested):

    edgeID = 18
    cut_point = (1.5,2,4)
    
    with open(r'D:\Temp\SolidMechanics.py') as f:
        cmds = f.read()
    exec(cmds)
    
    edge = ExtAPI.DataModel.GeoData.GeoEntityById(edgeID)
    selection=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
    selection.Ids = [edgeID]
    
    line_start= [edge.StartVertex.X,edge.StartVertex.Y,edge.StartVertex.Z]
    line_end= [edge.EndVertex.X,edge.EndVertex.Y,edge.EndVertex.Z]
    
    ratio,projection = project_pt2line(cut_point,line_start,line_end)
    
    if ratio > 0 and ratio < 1:
        virtual_topology.VirtualSplitEdge(selection,ratio)
    else:
        print "Cut point is not within the edge"