Constrain subassembly via Workpoint

Constrain subassembly via Workpoint

mk92
Collaborator Collaborator
582 Views
3 Replies
Message 1 of 4

Constrain subassembly via Workpoint

mk92
Collaborator
Collaborator

Hello,

i want to constrain a part in my assembly via workpoints. So i define the Point (Testpoint) in my assembly and the point in my subassembly (StartPoint).

And then i add the constraint. But i doesnt work.

 

What did i miss?

 

Regards

 

Dim wp As WorkPoint
wp = ThisDoc.Document.ComponentDefinition.WorkPoints("Testpoint")

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.Documents.ItemByName(ThisDoc.WorkspacePath()+"\Test.iam") 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition

Dim wp2 As WorkPoint
wp2 = oAsmDoc.ComponentDefinition.WorkPoints("StartPoint")

' add the constraint
oAsmCompDef.Constraints.AddMateConstraint(wp, wp2, 0)
0 Likes
583 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor

Geometry Proxies for using work features in a lower level document, I think.

 

oCylEdge1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeCircularFilter, "Select the lower most limit of the cylinder bore (Think insert constraint)")
oCylEdge2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeCircularFilter, "Select the lower most limit of the piston rod (Think insert constraint)")

For Each oWorkPlane In oCylEdge1.Parent.Parent.Definition.Document.ComponentDefinition.WorkPlanes
	oWorkPlane.Visible=True
Next
oCylOrigPlane1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select the origin plane of the cylinder")
For Each oWorkPlane In oCylEdge1.Parent.Parent.Definition.Document.ComponentDefinition.WorkPlanes
	oWorkPlane.Visible=False
Next
For Each oWorkPlane In oCylEdge2.Parent.Parent.Definition.Document.ComponentDefinition.WorkPlanes
	oWorkPlane.Visible=True
Next
oCylOrigPlane2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select the a co-planar origin plane of the rod")
For Each oWorkPlane In oCylEdge2.Parent.Parent.Definition.Document.ComponentDefinition.WorkPlanes
	oWorkPlane.Visible=False
Next
Dim oCompDef1 As ComponentDefinition = oCylOrigPlane1.Parent()
Dim oCompDef2 As ComponentDefinition = oCylOrigPlane2.Parent()

Dim oCompOcc1 As ComponentOccurrence = oAsmCompDef.Occurrences.AllReferencedOccurrences(oCompDef1).Item(1)
Dim oCompOcc2 As ComponentOccurrence = oAsmCompDef.Occurrences.AllReferencedOccurrences(oCompDef2).Item(1)

oCompOcc1.CreateGeometryProxy(oCylOrigPlane1, oAsmPlane1)
oCompOcc2.CreateGeometryProxy(oCylOrigPlane2, oAsmPlane2)

oMate1 = oAsmCompDef.Constraints.AddMateConstraint(oAsmPlane1, oAsmPlane2, 0)
With oMate1
        .Name = "COINCIDENT PLANE"
        .Offset.Expression = "0 in"
		.Suppressed = False
End With

There is an example of using proxies/making constraints. It was necessary to create the proxies to be able to access the PARTS Origin planes for use in constrains in the top level ASSEMBLY (directly up 1 level from them).

 

Good luck!

 

Edit: Looking at my methods, it is kind of convoluted because of the Pick method that I deemed necessary for my process. However, to use the proxies, all you need is the Occurrence containing the workfeatures, and the workfeatures themselves. So it might be easier for you.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 4

mk92
Collaborator
Collaborator
So if i get it right i need something like this:

Dim oPart2Plane1 As WorkPlaneProxy = Nothing oOcc2.CreateGeometryProxy(oPart2PlaneXZ, oPart2Plane1)

Just customized for my code.

But i dont get the part with the occurences. Can't i use the namens?
0 Likes
Message 4 of 4

MechMachineMan
Advisor
Advisor
Check the API and go from there.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes