Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: chandra.shekar.g

@chandra.shekar.g 

Hi Sir,

I wanted to constraint selected occurrences not all occurrences.

After I got few reply for my post I have done little changes to my Loop code and it is working fine now.

But If run the code again it is creating Angle constraints again, 

I want to include the condition " If the component already have angle constraint, new Angle constraint shouldn't create", Can you please help how add this condition on below code.

 

Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsm.ComponentDefinition
Dim oAxis1 As WorkAxis
Dim oAxis2 As WorkAxis
Dim oproxyAxis2 As WorkAxisProxy
Dim oAConstraint As AngleConstraint
Dim comps As New List(Of ComponentOccurrence)
For Each comp As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences
oFilename = comp.Definition.Document.displayname
If InStr(oFilename, "VLV_MAN") <> 0 Or InStr(oFilename, "VLV_HYD") <> 0 Then
comps.Add(comp)
End If
Next
' If there are selected components we can do something
For Each comp In comps
On Error Resume Next
oAxis1 = oAsmCompDef.WorkAxes.Item ("Y Axis")
oAxis2 = comp.Definition.WorkAxes("Y Axis")
comp.CreateGeometryProxy(oAxis2, oproxyAxis2)
oAConstraint = oAsmCompDef.Constraints.AddAngleConstraint(oproxyAxis2, oAxis1, 0, 78593)
'78594 refers to the undirected angle constraint solution type. 78593 refers to
'directed (which is default), and 78595 is the referenced vector solution

If oAConstraint.HealthStatus = oAConstraint.HealthStatus.kInconsistentHealth Then
oAConstraint.Delete
oAxis1 = oAsmCompDef.WorkAxes.Item("Z Axis")
oAxis2 = comp.Definition.WorkAxes("Y Axis")
comp.CreateGeometryProxy(oAxis2, oproxyAxis2)
oAConstraint = oAsmCompDef.Constraints.AddAngleConstraint(oproxyAxis2, oAxis1, 0, 78593)
'78594 refers to the undirected angle constraint solution type. 78593 refers to
'directed (which is default), and 78595 is the referenced vector solution
End If
Next

 

Thanks & Regards

Manoj Sampath