Imports System.IO
Imports System.Runtime.InteropServices
Module Example
<STAThread()> _
Sub Main()
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objPartDocument As SolidEdgePart.PartDocument = Nothing
Dim objStudyOwner As SolidEdgePart.StudyOwner = Nothing
Dim objStudy As SolidEdgePart.Study = Nothing
Dim objConstraintOwner As SolidEdgePart.ConstraintOwner = Nothing
Dim objConstraint As SolidEdgePart.Constraint = Nothing
Dim objFaceArray(1) As SolidEdgeGeometry.Face
Dim eConstraintDirection As SolidEdgePart.LoadSymbDirOptsEnum_Auto
Dim eConstraintType As SolidEdgePart.FEAConstraintTypeEnum_Auto
Dim dConstraintDirX As Double = 1.0
Dim dConstraintDirY As Double = 0.0
Dim dConstraintDirZ As Double = 0.0
Dim dConstraintPosX As Double = -0.0853057546724518
Dim dConstraintPosY As Double = 0.0
Dim dConstraintPosZ As Double = 0.039781012722987466
Dim dSpacingFactor As Double = 0.11
Dim dSizeFactor As Double = 0.24200000000000002
Dim dSteeringWheelLen As Double = 0.0
Dim dwConstraintProps As UInt32 = 0
Dim ColorConstraintSymbol As UInt32 = 16752704
Dim dConstraintSymSpacing As Double = 0.014476064557417175
Dim dConstraintSymSize As Double = 0.031847342026317789
Try
OleMessageFilter.Register()
' Connect to Solid Edge
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
objPartDocument = objApplication.ActiveDocument
objStudyOwner = objPartDocument.StudyOwner
objStudy = objStudyOwner.Item(1)
objStudy.GetConstraintOwner(objConstraintOwner)
eConstraintDirection = SolidEdgePart.LoadSymbDirOptsEnum_Auto.eLoadDirForCnstr_Auto
eConstraintType = SolidEdgePart.FEAConstraintTypeEnum_Auto.eCnstrTypePinned_Auto
' Populate objFaceArray
objConstraintOwner.AddConstraint(objFaceArray, _
eConstraintType, _
eConstraintDirection, _
dConstraintDirX, _
dConstraintDirY, _
dConstraintDirZ, _
dConstraintPosX, _
dConstraintPosY, _
dConstraintPosZ, _
ColorConstraintSymbol, _
dSpacingFactor, _
dSizeFactor, _
dSteeringWheelLen, _
dwConstraintProps, _
dConstraintSymSpacing, _
dConstraintSymSize, _
objConstraint)
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
OleMessageFilter.Revoke()
End Try
End Sub
End Module