SetConstraint

SetConstraint

Syntax

SapObject.SapModel.PointObj.SetConstraint

VB6 Procedure

Function SetConstraint(ByVal Name As String, ConstraintName As String, Optional ByVal ItemType As eItemType = Object, Optional ByVal Replace As Boolean = True) As Long

Parameters

Name

The name of an existing point object or group depending on the value of the ItemType item.

ConstraintName

The name of an existing joint constraint.

ItemType

This is one of the following items in the eItemType enumeration:

Object = 0

Group = 1

SelectedObjects = 2

If this item is Object, the constraint assignment is made to the point object specified by the Name item.

If this item is Group, the constraint assignment is made to all point objects in the group specified by the Name item.

If this item is SelectedObjects, the constraint assignment is made to all selected point objects and the Name item is ignored.

Replace

If this item is True, all previous joint constraints, if any, assigned to the specified point object(s) are deleted before making the new assignment.

Remarks

This function makes joint constraint assignments to point objects.

The function returns 0 if the assignment is successfully made, otherwise it returns nonzero.

VBA Example

Sub SetConstraintAssignment()

'dimension variables

Dim SapObject as cOAPI

Dim SapModel As cSapModel

Dim ret As Long

Dim i As Long

'create Sap2000 object

Set SapObject = CreateObject("CSI.SAP2000.API.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.New2DFrame(PortalFrame, 3, 124, 3, 200)

'define a new constraint

ret = SapModel.ConstraintDef.SetDiaphragm("Diaph1")

'define new constraint assignments

For i = 4 To 16 Step 4

ret = SapModel.PointObj.SetConstraint(Format(i), "Diaph1")

Next i

'close Sap2000

SapObject.ApplicationExit False

Set SapModel = Nothing

Set SapObject = Nothing

End Sub

Release Notes

Initial release in version 11.00.

Modified optional argument Replace to be ByVal in version 12.0.1.

See Also

GetConstraint

DeleteConstraint