SapObject.SapModel.SolidObj.AddByCoord
Function AddByCoord(ByRef x() As Double, ByRef y() As Double, ByRef z() As Double, ByRef Name As String, Optional ByVal PropName As String = "Default", Optional ByVal UserName As String = "", Optional ByVal CSys As String = "Global") As Long
x, y, z
These are arrays of x, y and z coordinates, respectively, for the corner points of the solid object. The coordinates are in the coordinate system defined by the CSys item.
Name
This is the name that the program ultimately assigns for the solid object. If no UserName is specified, the program assigns a default name to the solid object. If a UserName is specified and that name is not used for another solid object, the UserName is assigned to the solid object; otherwise a default name is assigned to the solid object.
PropName
This is either Default or the name of a defined solid property.
If it is Default, the program assigns a default solid property to the solid object. If it is the name of a defined solid property, that property is assigned to the solid object.
UserName
This is an optional user specified name for the solid object. If a UserName is specified and that name is already used for another solid object, the program ignores the UserName.
CSys
The name of the coordinate system in which the solid object point coordinates are defined.
This function adds a new solid object whose corner points are at the specified coordinates. Note that solid objects always are defined with eight corner points.
The function returns zero if the solid object is successfully added; otherwise it returns a nonzero value.
Sub AddSolidObjByCoord()
'dimension variables
Dim SapObject As Sap2000.SapObject
Dim SapModel As cSapModel
Dim ret As Long
Dim x() As Double
Dim y() As Double
Dim z() As Double
Dim Name As String
'create Sap2000 object
Set SapObject = New SAP2000.SapObject
'start Sap2000 application
SapObject.ApplicationStart
'create SapModel object
Set SapModel = SapObject.SapModel
'initialize model
ret = SapModel.InitializeNewModel
'create model from template
ret = SapModel.File.NewBlank
'add solid object by coordinates
ReDim x(7)
ReDim y(7)
ReDim z(7)
x(0) = 0: y(0) =
0: z(0) = 0
x(1) = 100: y(1) = 0:
z(1) = 0
x(2) = 0: y(2) =
100: z(2) = 0
x(3) = 100: y(3) = 100:
z(3) = 0
x(4) = 0: y(4) =
0: z(4) = 100
x(5) = 100: y(5) = 0:
z(5) = 100
x(6) = 0: y(6) =
100: z(6) = 100
x(7) = 100: y(7) = 100:
z(7) = 100
ret = SapModel.SolidObj.AddByCoord(x,
y, z, Name)
'refresh view
ret = SapModel.View.RefreshView(0,
False)
'close Sap2000
SapObject.ApplicationExit False
Set SapModel = Nothing
Set SapObject = Nothing
End Sub
Initial release in version 11.00.