- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
The Loop Code is working fine to select the components.
I need to constraint these selected gate valves with respect to Assembly "Y Axis"
So I have created below Loop code by using your suggested Code, But I'm getting error while run the rule.
Can you please help to find the error in below code
Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsm.ComponentDefinition
Dim oAxis1 As WorkAxis
Dim oAxis2 As WorkAxis
Dim oproxyAxis1 As WorkAxisProxy
Dim oAConstraint As AngleConstraint
Dim comps As ObjectCollection
Dim comp As ComponentOccurrence
comps = ThisApplication.TransientObjects.CreateObjectCollection
comp = oAsmCompDef.Occurrences
oFilename = comp.Definition.Document.displayname
If InStr(oFilename, "VLV_MAN") <> 0 Then
ThisApplication.CommandManager.DoSelect(comp)
End If
If InStr(oFilename, "VLV_HYD") <> 0 Then
ThisApplication.CommandManager.DoSelect(comp)
End If
comps.Add(comp)
' If there are selected components we can do something
For Each comp In comps
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
Next
Thanks & Regards,
Manoj Sampath