How to Redefine Sketch with iLogic and Maintain Full-Constraint Status

How to Redefine Sketch with iLogic and Maintain Full-Constraint Status

JBerns
Advisor Advisor
938 Views
6 Replies
Message 1 of 7

How to Redefine Sketch with iLogic and Maintain Full-Constraint Status

JBerns
Advisor
Advisor

Dear Community,

 

I have a part that I would like to be able to redefine a sketch and maintain its fully-constrained status.

 

If I redefine the sketch manually, the full-constraint status is maintained regardless of the number of Redefine operations that are performed.

 

However, when I use iLogic code to redefine the sketch, the full-constraint status is lost after the second operation.

See video here: https://autode.sk/2Zhs7yU 

 

How can I modify the iLogic code to maintain the full-constraint status regardless of the number of Redefine operations performed?

 

I suspect there is a problem in how I specify the Workplanes, WorkPoints, and WorkAxes. A portion of the iLogic follows. I have attached the part.

Sketch.Redefine(oDef.Sketches.Item(1).Name, partDef.WorkPlanes.Item(i).Name, partDef.WorkPoints(1).Name, partDef.WorkAxes(j).Name, AxisIsX := True, NaturalAxisDirection := True)

Thank you for your time and attention. I look forward to your replies.

 

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
939 Views
6 Replies
Replies (6)
Message 2 of 7

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Try this:

Public Sub SketchRedef()
    ' Get the active part document.
    Dim partDoc As PartDocument
    partDoc = ThisApplication.ActiveDocument
    Dim partDef As PartComponentDefinition
    partDef = partDoc.ComponentDefinition

    Dim sketch As PlanarSketch
    sketch = partDef.Sketches.Item(1)
    
    sketch.PlanarEntity = partDef.WorkPlanes.Item(1)

    ThisApplication.ActiveView.Fit
End Sub

or for VBA:

Public Sub SketchRedef()
    ' Get the active part document.
    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveDocument
    Dim partDef As PartComponentDefinition
    Set partDef = partDoc.ComponentDefinition

    Dim sketch As PlanarSketch
    Set sketch = partDef.Sketches.Item(1)
    
    sketch.PlanarEntity = partDef.WorkPlanes.Item(1)

    ThisApplication.ActiveView.Fit
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 7

JBerns
Advisor
Advisor

@bradeneuropeArthur,

 

I should have clarified to review the code in the part.

 

Were you able to test this code with the existing code in the part?

 

The interface allows the user to select a Sketch (Work) Plane. After the first selection, the sketch is still fully-constrained. However, after the second plane selection, the full-constraint status is lost. I show this failure in the video. Hope it is helpful.

 

At a quick glance, I think your code will only  select the XY plane, correct?

 

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 4 of 7

bradeneuropeArthur
Mentor
Mentor

My sketch was fully constraint on the initial workplane, and is also after it have been redefined on the new workplane.

xz.PNGyz.PNG

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 7

bradeneuropeArthur
Mentor
Mentor

For testing your file, I am missing a derived part!

It is asking for a link.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 7

JBerns
Advisor
Advisor

@bradeneuropeArthur,

 

Would you tell me the file name the link requires or provide a screen capture? I am sure the link can be deleted.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 7 of 7

shastu
Advisor
Advisor

What if you want to have the user Redefine an existing sketch to a face that they select?  In VBA please.

0 Likes