Adding new mark feature to flat pattern with ilogic

Adding new mark feature to flat pattern with ilogic

brianA32ZM
Advocate Advocate
887 Views
10 Replies
Message 1 of 11

Adding new mark feature to flat pattern with ilogic

brianA32ZM
Advocate
Advocate

Hello, I looking for help automating the new mark feature (Inventor 2023). Manually I can add it to the flat pattern, however with iLogic it appears that that "MarkFeatures" is missing in Flatpattern.Features (see image below).

 

The following works when adding the mark feature to the folded model:

Dim oMark As MarkFeature

oMark = ThisApplication.ActiveDocument.ComponentDefinition.Features.Add(oMarkDef)

 

My issue is when trying to add a mark feature to the flat pattern:

Dim oMark As MarkFeature

oMark = ThisApplication.ActiveDocument.ComponentDefinition.FlatPattern.Features.Add(oMarkDef)

 

With out "MarkFeatures" is there a way to add a Mark Features to the flat pattern features?  

 

brianA32ZM_1-1661629137653.png

 

 

 

 

888 Views
10 Replies
Replies (10)
Message 2 of 11

WCrihfield
Mentor
Mentor

Hi @brianA32ZM.  I am still using Inventor Pro 2022.3.1, but after reviewing the 2023 online help documentation for all three part related feature collections [PartFeatures (Link, Link), SheetMetalFeatures (Link, Link), FlatPatternFeatures (Link, Link)], it sure looks like MarkFeature(s) are not supported within the FlatPattern.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 11

brianA32ZM
Advocate
Advocate

Thank you WCrihfield. It is strange that the mark command can be used manually on a flat pattern, but not via programing. Seems like an oversite. 

In a second attempt I called the mark command as if the mark button was selected:

	Dim oCopyControlDef As ControlDefinition
    oCopyControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartMarkingCmd")
    oCopyControlDef.Execute

 This method led to the following error:

    Create Mark Feature failed
    Stack Blade Stop Right.ipt: Errors occurred during update
    Mark3: Could not build this Mark
    An error occurred: these faces doesn't intersect with the split tool.

 

0 Likes
Message 4 of 11

grahov
Participant
Participant

Hello. I have found a solution.
The oCompDef must be As SheetMetalComponentDefinition

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

and part of the code for FlatPattern

'==================== Creating an Objectcollection to be Marked ======================
Dim oSketchObjects As ObjectCollection
oSketchObjects = ThisApplication.TransientObjects.CreateObjectCollection
    
' Get all entities in the sketch
Dim oSketchText As TextBox
For Each oSketchText In oSketch.TextBoxes
oSketchObjects.Add(oSketchText)
Next

'==================== Creating the Mark on the textbox  ======================

Dim oFlat As FlatPatternFeatures
oFlat = oCompDef.FlatPattern.Features 

Dim oMarkFeatures As MarkFeatures
oMarkFeatures = oflat.MarkFeatures
    
'Get a mark style.
Dim oMarkStyle As MarkStyle
oMarkStyle = oPartDoc.MarkStyles.Item(1)
    
'Create mark definition.
Dim oMarkDef As MarkDefinition
oMarkDef = oMarkFeatures.CreateMarkDefinition(oSketchObjects, oMarkStyle)
	
'Create a mark feature.
Dim oMark As MarkFeature
oMark = oMarkFeatures.Add(oMarkDef)

'====================   

 

0 Likes
Message 5 of 11

brianA32ZM
Advocate
Advocate

Thank you.

After my original post I believe a patch provided an update that allowed MarkFeatures to be added to the FlatPattern:

 

brianA32ZM_0-1701351680240.png

 

 

0 Likes
Message 6 of 11

grahov
Participant
Participant
cool!
please tell me where to find such a list as in the screenshot?
0 Likes
Message 7 of 11

brianA32ZM
Advocate
Advocate

typo sorry; should be: ThisApplication.ActiveDocument

 

brianA32ZM_0-1701352646573.png

 

 

Message 8 of 11

grahov
Participant
Participant
Perfectly! Thank you very much!
0 Likes
Message 9 of 11

brianA32ZM
Advocate
Advocate
No problem, that opened my eyes to the world of programming. Enjoy!
Message 10 of 11

vishnuteja_srikanti
Participant
Participant

still  i am facing issue using this code 

 

0 Likes
Message 11 of 11

WCrihfield
Mentor
Mentor

Hi @vishnuteja_srikanti.  What version/year and release of Inventor are you using?  See attached text file for an example iLogic rule you can try out.  I just tested that code again on a local test sheet metal part and it seemed to work OK for me.  This example is just using the 'first' MarkStyle available in the Document, without checking which one that is, or which type it is.  Some types only mark the surface, while other types mark all the way through the material.  It is also just using a simple Inventor.TextBox containing the file's name, as what to 'Mark' the face with.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes