07-22-2019
04:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-22-2019
04:59 AM
@Anonymous,
Try below iLogic 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
Dim oAngle As Boolean
oAngle = False
Dim oConstraint As AssemblyConstraint
For Each oConstraint In comp.Constraints
If oConstraint.Type = kAngleConstraintObject Then
oAngle = True
End If
Next
If oAngle = False Then
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
End If
Next
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network
