스터디의 개체는 절점, 삼각형, 4면체 등의 각 개체 유형에 대한 목록 같은 링크된 목록을 통해 사용할 수 있습니다. 이 예에서는 여러 루프를 구현해 유형별로 각 개체를 살펴봅니다.
이 스크립트는 다음 작업을 수행합니다.
절점 데이터를 읽고 싶을 때 이 스크립트를 사용할 수 있습니다.
'%RunPerInstance
'@
'@ 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 SynergyGetter, Synergy
On Error Resume Next
Set SynergyGetter = GetObject(CreateObject("WScript.Shell").ExpandEnvironmentStrings("%SAInstance%"))
On Error GoTo 0
If (Not IsEmpty(SynergyGetter)) Then
Set Synergy = SynergyGetter.GetSASynergy
Else
Set Synergy = CreateObject("amiws.Synergy")
End If
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