Create SECOND associative WorkPoint on intersection of WorkAxis with CYLINDER Face

Create SECOND associative WorkPoint on intersection of WorkAxis with CYLINDER Face

Maxim-CADman77
Advisor Advisor
460 Views
1 Reply
Message 1 of 2

Create SECOND associative WorkPoint on intersection of WorkAxis with CYLINDER Face

Maxim-CADman77
Advisor
Advisor

I need to create associative (auto-updating on parent entity changes) WorkPoint(s) at intersection of a given WorkAxis with a given flat/cylindrical Face.

 

The only workaround* way I've found till now is to prepare SelectSet and than execute UI command  "PartCurveSurfaceWorkPointCmd" on it.

 

My current iLogic-code is:

 

 

Sub Main

dim oIPT as PartDocument

if Not ThisApplication.ActiveDocument.DocumentType.ToString().StartsWith("kPart")
	logger.debug ("Active doc should be Part")
	Exit Sub
else
	oIPT = ThisApplication.ActiveDocument' ThisDoc.Document
end if

dim oCmdMgr As CommandManager = ThisApplication.CommandManager

if oIPT.ComponentDefinition.SurfaceBodies.Count = 0
	logger.debug ("Cancelled (No bodies/faces)")
	Exit Sub
end if

dim oSelSet as SelectSet = oIPT.SelectSet

dim oWA as WorkAxis = oCmdMgr.Pick(kWorkAxisFilter, "Pick the WorkAxis")
oSelSet.Select(oWA)

dim oFace as Face = oCmdMgr.Pick(kPartFaceFilter, "Pick the Face") ' to be somehow limited to oSB.Faces only
oSelSet.Select(oFace)

oCmdMgr.ControlDefinitions("PartCurveSurfaceWorkPointCmd").Execute

End Sub

 

 

This works OK for simple cases like planar face, but for cylindric face it creates only one WorkPoint (see the attached Inventor 2022 sample).

 

I'd like to know how can I create both associative WorkPoints.

 

* I believe there should be some WorkPoint.Add... method but I can't find it.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Accepted solutions (1)
461 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor
Accepted solution

This is the minimalistic sample code for your Simple_Sample.ipt

Dim part As PartDocument = ThisDoc.Document
Dim wAxis As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkAxisFilter, "Pick axis")
Dim oFace As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Face")
part.ComponentDefinition.WorkPoints.AddByCurveAndEntity(wAxis, oFace)

You are not able to manage (in this sample) which of two solutions will be used.

 

Here is more complex sample where all solutions are used (two work points are created)

Dim part As PartDocument = ThisDoc.Document
Dim wAxis As WorkAxis = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkAxisFilter, "Pick axis")
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Face")

Dim solutions = wAxis.Line.IntersectWithSurface(oFace.Geometry)
For Each pt As Point In solutions
    part.ComponentDefinition.WorkPoints.AddByCurveAndEntity(wAxis, oFace, pt)
Next

I hope it helps

0 Likes