Create workpoint in Sketch3D using iLogic

Create workpoint in Sketch3D using iLogic

StKrause
Contributor Contributor
176 Views
3 Replies
Message 1 of 4

Create workpoint in Sketch3D using iLogic

StKrause
Contributor
Contributor

Hello,

I'm trying to create a workpoint as child of a sketch3D. At the UI you can activate a 3D-sketch and create a workpoint. This workpoint will be a child of the sketch.

How to create such a child workpoint using ilogic?

StKrause_0-1739266044023.png

 

0 Likes
177 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @StKrause.  I suspect that the WorkPoint we create would need to be 'dependent' on something in the Sketch3D, before it would become a 'child' of that Sketch3D.  Your code is just creating a new Sketch3D, with no geometry in it, activating it, then creating a 'Fixed' WorkPoint at a transient point location, which would not be dependent on anything, then exiting the sketch.  I think after you create the Sketch3D, you would need to create a SketchPoint3D (SketchPoints3D.Add) in it at the required point, then use the WorkPoints.AddByPoint method to associate the new WorkPoint with that SketchPoint3D object, which will create the 'dependency' needed.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

StKrause
Contributor
Contributor

Hello @WCrihfield ,

 

I have changed the rule to:

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oWPts As WorkPoints = oCompDef.WorkPoints
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

'create Sketch3D
Dim oSk3D As Sketch3D = oCompDef.Sketches3D.Add
'edit sketch
oSk3D.Edit
'create transient point
Dim oPt As Point = oTG.CreatePoint(1, 2, 3)
'create SketchPoint3D
Dim oSkPt As SketchPoint3D = oSk3D.SketchPoints3D.Add(oPt, True)
'create WorkPoint using SketchPoint3D
Dim oWPt As WorkPoint = oWPts.AddByPoint(oSkPt, False)
'exit sketch
oSk3D.ExitEdit

But the workpoint also is generated outside the 3D-sketch.

At UI you can create workpoints inside the 3D-sketch without adding sketchpoints before.

The API has a WorkPoint.ParentSketch, but this is a readonly property.

It seams not possible to create workpoints inside a 3D-sketch using the API.

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Hi @StKrause.  I did some local testing this morning and I agree that only seems to work out that way when manually doing it in the user interface, and not by doing it through the API.  I am not sure why this small detail is important, but it is certainly interesting.  There are still lots of things that we still can not do through the Inventor API that we can do manually.  In this case, it seems that we can create all the objects necessary by code, but simply can not simulate the parent <> child relationship between them visibly apparent in the model browser tree.  This may another one of those situations where there are some additional 'behind the scenes helpers' involved when doing things the 'manual' way that we do not see or know about.  That helper may be automatically rearranging the browser nodes when that sequence of events happens.  Maybe we can access the model browser nodes ourselves, and attempt to force the one node to become a child node of the other.  I do know that we have access to those nodes by code, but have not tried this highly scenario specific task before.  Just some additional thoughts.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes