How to create a Beam in Spaceclaim?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 389
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
edited June 2023 in 3D Design

How to create a Beam in Spaceclaim?

Tagged:

Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 389
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    Answer ✓
    # Python Script, API Version = V18
    startPoint=Point.Create(1,0,0)
    endPoint=Point.Create(5,0,0)
    lineSegment = CurveSegment.Create(startPoint,endPoint)
    part =  GetRootPart()
    designLine = DesignCurve.Create(part,lineSegment)
    
    profile=BeamProfile.CreateDisk(10,"MyProfile")
    beamProfile=part.Components[0].Template
    beamGen = SpaceClaim.Api.V18.Beam.Create(beamProfile,designLine)
    beamGen.SetName("My beam")
    
  • Aria
    Aria Member, Employee Posts: 64
    First Anniversary Ansys Employee First Answer Name Dropper
    Answer ✓

    If you're using the V19 API, it works just as well:

    # Python Script, API Version = V19
    import SpaceClaim.Api.V19.Beam as Beam
    startPoint=Point.Create(1,0,0)
    endPoint=Point.Create(5,0,0)
    lineSegment = CurveSegment.Create(startPoint,endPoint)
    part =  GetRootPart()
    designLine = DesignCurve.Create(part,lineSegment)
    
  • Vishnu
    Vishnu Member, Employee Posts: 198
    Name Dropper First Anniversary Solution Developer Community of Practice Member First Comment
    Answer ✓

    In V21 API:

    def createcircularbeams(pointlist,outerdia,innerdia,name):
        '''
        **************************************************************************
        Create circular beams in spaceclaim using points 
        way to use : createcircularbeams([(0,0,0),(100,0,0),(200,0,0)],20,10,'MyBeam')
        **************************************************************************
        '''
        curves = []
        for previous, current in zip(pointlist, pointlist[1:]):
            point1 = Point.Create(previous[0], previous[1], previous[2])
            point2 = Point.Create(current[0], current[1], current[2])
            line1 = SketchLine.Create(point1,point2)
            profile1 = BeamProfile.CreateCircular(outerdia,innerdia,name)
            curves.append(line1.CreatedCurves[0])
        selection_curve = Selection.Create(curves)
        selection_profile = Selection.CreateByNames(name+'_Circle')
        beams = Beam.Create(selection_curve,selection_profile)   
        createdbeams = beams.CreatedBeams
        selection_beams = Selection.Create(createdbeams)
        component = ComponentHelper.CreateAtRoot(name)
        ComponentHelper.MoveBodiesToComponent(selection_beams, component, False, None)    
        component.Content.ShareTopology = component.Content.ShareTopology.Share