- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Friends, I'm trying to constraint "Z Axis" of 'placed component' with the "Y Axis" of 'active assembly document' but its giving error at the syntax of "Set oMateConstraint3 = oAssemblyConstraints3.AddMateConstraint(oActiveAssemblyYAxis, oSecondPlacedComponentZAxis, 0)".
Error is "Method 'AddMateConstraint' of object 'AssemblyConstraints' failed.
Please let me know, what's wrong I'm doing?
' Find the second placed component occurrence by its occurrence name
Dim secondPlacedComponentOccurrenceName As String
secondPlacedComponentOccurrenceName = "AB150N LH_CAD Atmn:1" ' Replace with the actual occurrence name of the second placed component
' Get the second placed component occurrence
Dim oSecondPlacedComponentOccurrence As ComponentOccurrence
Set oSecondPlacedComponentOccurrence = oAssemblyDef.Occurrences.ItemByName("AB150N LH_CAD Atmn:1")
' Get the "Y Axis" of the active assembly document
Dim oActiveAssemblyYAxis As WorkAxis
Set oActiveAssemblyYAxis = oAssemblyDef.WorkAxes.Item("Y Axis") ' Replace with the actual Y Axis name
' Get the "Z Axis" of the second placed component
Dim oSecondPlacedComponentZAxis As WorkAxis
Set oSecondPlacedComponentZAxis = oSecondPlacedComponentOccurrence.Definition.WorkAxes.Item("Z Axis") ' Replace with the actual Z Axis name
' Create a work axis proxy for the sub-component
Dim oSecondPlacedComponentWorkAxisProxy As WorkAxisProxy
Call oSecondPlacedComponentOccurrence.CreateGeometryProxy(oSecondPlacedComponentZAxis, oSecondPlacedComponentWorkAxisProxy)
' Add the mate constraint between the two work axes
Dim oAssemblyConstraints3 As AssemblyConstraints
Set oAssemblyConstraints3 = oAssemblyDef.constraints
Dim oMateConstraint3 As mateConstraint
Set oMateConstraint3 = oAssemblyConstraints3.AddMateConstraint(oActiveAssemblyYAxis, oSecondPlacedComponentZAxis, 0)
Solved! Go to Solution.