Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I Wrote this code to create a Plane and constrained it with a Work Plane in a Part. This works until the last line of the code where it throws me an error.
oPart = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a Part")
oPlane1 = oPart.Definition.WorkPlanes.Item("UCS_TOP: XY Plane")
MessageBox.Show(oPlane1.name, "Title")
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Try
oAsmCompDef.WorkPlanes.Item("Plano_2").Delete
Catch
'Do nothing
End Try
oPlane2 = oAsmCompDef.WorkPlanes.AddFixed(oTG.CreatePoint(0,0,0),oTG.CreateUnitVector(0,0,1),oTG.CreateUnitVector(0,1,0),False)
oPlane2.Name = "Plano_2"
MessageBox.Show(oPart.name , "Title")
'Constraints.AddMate("Mate:20", "", oPlane2.Name, "SKELETON_SC_JM_02:1" , "UCS_TOP: XY Plane")
Constraints.AddMate("Mate:20", "", oPlane2.Name, oPart.name, "UCS_TOP: XY Plane")
If I activate the line 23, the rule works correctly, but if I activate the line 24 ( deactivating the line 23). The code does everything except the constraint, showing the following error
Error in rule: Rule3, in document: SC_JM_02.iam
Unable to cast object of type 'System.String' to type 'Autodesk.iLogic.Types.ComponentArgument'.
How can I fix it?
Solved! Go to Solution.