您可以透過連結清單使用研究中的圖元,每種圖元類型 (例如節點、三角形、四面體等) 一個。此範例會執行多個迴圈,以查看每種類型的每個圖元。
此指令碼會執行以下工作:
當您想讀取節點資料時,可以使用此指令碼。
'@ '@ DESCRIPTION '@ Example of how to loop through entities using the API '@ '@ SYNTAX '@ LoopThroughEntities '@ '@ PARAMETERS '@ none '@ '@ DEPENDENCIES/LIMITATIONS '@ none '@ '@ History '@ Created DRA 9/8/2006 '@@ Option Explicit SetLocale("en-us") Dim Synergy Set Synergy = CreateObject("synergy.Synergy") Synergy.SetUnits "METRIC" Dim StudyDoc Dim MaxNumber, Node, NodeNumber, Count, Tri, Tet, Beam Set StudyDoc = Synergy.StudyDoc ' Loop through all nodes and find the highest Node Number MaxNumber = 0 Set Node = StudyDoc.GetFirstNode() While Not Node Is Nothing NodeNumber = StudyDoc.GetEntityID(Node) If NodeNumber > MaxNumber Then MaxNumber = NodeNumber End if Set Node = StudyDoc.GetNextNode(Node) Wend MsgBox "Maximum Node Number in Model is: " & CStr(MaxNumber) ' Count all Triangular Elements in the Model Count = 0 Set Tri = StudyDoc.GetFirstTri() While Not Tri Is Nothing Count = Count + 1 Set Tri = StudyDoc.GetNextTri(Tri) Wend MsgBox "Model Contains " & CStr(Count) & " Triangular Elements" ' Count all Tet Elements in the Model Count = 0 Set Tet = StudyDoc.GetFirstTet() While Not Tet Is Nothing Count = Count + 1 Set Tet = StudyDoc.GetNextTet(Tet) Wend MsgBox "Model Contains " & CStr(Count) & " Tet Elements" ' Count all Beam Elements in the Model Count = 0 Set Beam = StudyDoc.GetFirstBeam() While Not Beam Is Nothing Count = Count + 1 Set Beam = StudyDoc.GetNextBeam(Beam) Wend MsgBox "Model Contains " & CStr(Count) & " Beam Elements" MsgBox "Script Complete" Wscript.Quit