Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Sergio.D.Suárez
in reply to: Anonymous

try the following code, I think it could work, I have placed the instruction on error resume next in the last for-next in case errors are generated in this sector, should control this sector of code then, if the previous block works. regards

 

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 = ThisApplication.TransientObjects.CreateObjectCollection

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
Next

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn