
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I have a bolt assembly with 1 bolt 2 washers and a nut.
I use the macro to insert the assembly and want to constrain a washer of that assembly to a selected hole in the main assembly.
The insertconstraint is failing. I tried the same thing with just a washer and that works fine.
So either I am doing something wrong with selecting the correct edge of the washer inside the assembly, or I need to change something with the insert constraint itself.
I did add a check to see if the edge I'm using is indeed a circle.
error returned:
run time error 80004005:
Method 'Addinsertconstraint' of object "assemblyconstraints' failed
I stripped below code from the bigger macro to be more clear.
- select a circle edge in the existing assembly
- Macro will place the assembly M10 x 25.iam
- Fails to constrain
Any help would be appreciated.
Bolt assembly is attached. inside are standard content centre bolt washers and nut.
Thx
Public Sub test_assy_constraint() Dim oAsmCompDef As AssemblyComponentDefinition Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition Dim oEdge As Edge Dim oFace As Face Set oEdge = ThisApplication.CommandManager.Pick(kPartEdgeCircularFilter, "select circular edge") If oEdge Is Nothing Then Exit Sub Else If Not oEdge.GeometryType = kCircleCurve Then GoTo Line1 End If End If Dim memberfilename As String memberfilename = "c:\testfolder\bolts\M10 x 25.iam" 'memberfilename = "c:\testfolder\inventor content center\Content center 3D Suppliers 2019\en-US\DIN 125-1 A\DIN 125 - A 10,5.ipt" Dim transMatrix As Matrix Set transMatrix = ThisApplication.TransientGeometry.CreateMatrix Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition Dim occ As ComponentOccurrence Set occ = oAsmCompDef.Occurrences.Add(memberfilename, transMatrix) Dim oInsert As InsertConstraint Dim oEdge3 As Edge Set oEdge3 = occ.Definition.Occurrences.Item(2).SurfaceBodies.Item(1).Edges.Item(1) 'item 2 = washer 'Set oEdge3 = occ.SurfaceBodies.Item(1).Edges.Item(1) If Not oEdge3.GeometryType = kCircleCurve Then MsgBox ("not a circle") End If 'On Error Resume Next Set oInsert = oAsmCompDef.Constraints.AddInsertConstraint(oEdge, oEdge3, True, 0) 'Set oinsert = oAsmcompdef.Constraints.AddInsertConstraint2(oedge, oEdge3, True, 0) End Sub
Solved! Go to Solution.