I have a design in SpaceClaim that contains several beams, nested in components and subcomponents and I would like to extract a list of all the beams along with location and section properties for design validation.
Here are some options to extract a list of your beams in SpaceClaim using scripting:
Using the following will extract only top-level beams (will miss beams that are nested in components and sub-components):
all_beams = GetRootPart().Beams
You can use the following will extract all beams from your design:
all_beams = GetRootPart().GetDescendants[IBeam]()
Note that the line above will extract some beams as BeamGeneral object type, instead of Beam. The first object type is missing some properties, so it is advised to retrieve the “Beam” object out of these as well. To do this conversion you can use the .Master routine. Here is a simple example for SpaceClaim API v22, which you can use when iterating over your list of beams before extracting properties:
BeamGeneral
Beam
.Master
for beam in all_beams: if str(beam.GetType()) == "SpaceClaim.Api.V22.BeamGeneral": beam = beam.Master
Here is a list of useful beam properties you can extract with Scripting:
beam.Shape.StartPoint
beam.Shape.EndPoint
beam.Shape.Length
beam.SectionAngle
beam.SectionProperties.Area
beam.SectionProperties.Ixx
beam.SectionProperties.Centroid