Virtual Topology [Split Edge at +]

Options
Akane Ito
Akane Ito Member Posts: 24
First Comment Name Dropper
edited July 9 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 Posts: 237
    First Answer First Comment 5 Likes First Anniversary
    edited July 9
    Options
    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: 24
    First Comment Name Dropper
    Options

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

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 237
    First Answer First Comment 5 Likes First Anniversary
    edited July 10
    Options

    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"