Automating End Release Assignment to Line Bodies
Hello,
I have been attempting to add end releases to an imported line body model. The model has shared topology from the discovery export.
There are 8 edges, 9 vertices in my model. The code I have is producing 8 end releases, however, an end release can only be scoped to a vertex which connects to more than 1 beam, as such in my model I should only have 6 end releases.
printing vertex_beam_count produces:
{247: 2, 248: 1, 251: 2, 252: 2, 253: 2, 254: 2, 257: 1, 258: 3, 259: 1}
So that's behaving correctly, showing 6 vertices with more than one beam attached.
Where am I going wrong with the logic, am I approaching it all wrong?
Any help appreciated - thanks!
# Beam Model Setup # Section 1 - General Setup model = ExtAPI.DataModel.Project.Model geom = model.Geometry mesh = model.Mesh connections = model.Connections materials = model.Materials analysis = model.Analyses[0] solution = analysis.Solution # Section 4 - Create end Releases at each qualifying vertex (more than one beam connected) Verts = [] Edges = [] with Transaction(): # Loop through all assemblies, parts, and bodies for Assembly in ExtAPI.DataModel.GeoData.Assemblies: for Part in Assembly.AllParts: for Body in Part.Bodies: for Edge in Body.Edges: Edges.append(Edge) # Collect vertices from edges for Vertex in Edge.Vertices: Verts.append(Vertex) # Dictionary to count connections at each vertex using vertex ID vertex_beam_count = {} # Count beams (edges) connected to each vertex for edge in Edges: for vertex in edge.Vertices: vertex_id = vertex.Id # Use unique identifier for each vertex if vertex_id not in vertex_beam_count: vertex_beam_count[vertex_id] = 0 vertex_beam_count[vertex_id] += 1 # Set to track edges where end releases have already been added processed_edges = set() # Add end releases only at edges connected by vertices with more than one beam with Transaction(): for edge in Edges: edge_id = edge.Id # Unique ID of the edge # Check if either of the edge's vertices has more than one connected beam if edge_id not in processed_edges and any(vertex_beam_count[vertex.Id] > 1 for vertex in edge.Vertices): # Add an end release to the current edge end_release = connections.AddEndRelease() processed_edges.add(edge_id) # Mark edge as processed to avoid duplicates # Configure end release properties if needed
Answers
-
Hey @JoeyBoy thanks for posting! Someone in the @AKD-Scripting-Team might be able to help you.
0