Ascending numbering in the component from 1-300

Ascending numbering in the component from 1-300

infoXFJXM
Explorer Explorer
644 Views
11 Replies
Message 1 of 12

Ascending numbering in the component from 1-300

infoXFJXM
Explorer
Explorer


I need 300 sheets with ascending numbering in the component from 1-300.
Is there a possibility that Inventor 2023 will be able to generate the components automatically?

Via macro or iLogic?

I am an absolute layman in this field

 

infoXFJXM_0-1738154140347.png

 

0 Likes
Accepted solutions (3)
645 Views
11 Replies
Replies (11)
Message 2 of 12

tdant
Collaborator
Collaborator

Stuff like this is very doable in Inventor through a few different channels. If you're able to provide the part file, I can work something up and talk you through how I did it.

0 Likes
Message 3 of 12

C_Haines_ENG
Collaborator
Collaborator

Do you mean that it would create a new part? This code will do that. You enter what number you'd like to start at, and what number you'd like to end at. You can try and use it in the attached part file.

 

Sub Main

	Dim oDoc As PartDocument = ThisDoc.Document

	Dim oPath As String = ThisDoc.Path & "\"

	Dim oEmboss As EmbossFeature = oDoc.ComponentDefinition.Features.EmbossFeatures(1)

	Dim oStart As Integer = Int(InputBox("Enter Starting #", "Plate Duplicator", "1"))
	If oStart < 1 Then Exit Sub
		
	Dim oEnd As Integer = Int(InputBox("Enter End #", "Plate Duplicator", "2"))
	If oEnd < 2 Then Exit Sub

	Dim oSketch As Sketch = oEmboss.Profile.Parent
	Dim oTextBox As Inventor.TextBox = oSketch.TextBoxes(1)
	Dim oFontSize As Double = Split(Split(oTextBox.FormattedText, "'>")(0), "<StyleOverride FontSize='")(1)

	For i = oStart To oEnd

		Dim oText As String = i & "-"
		oTextBox.FormattedText = "<StyleOverride FontSize = '" & oFontSize & "'>" & oText & "</StyleOverride>"
		oDoc.Update
		
		Dim oDocName As String = "PLATE #" & i
		oDoc.SaveAs(oPath & oDocName & ".ipt", True)
		Logger.Info("Ran Once!")

	Next

End Sub

 

0 Likes
Message 4 of 12

J-Camper
Advisor
Advisor
Accepted solution

Depending on what you want to do with these parts, you might not even need iLogic.  ModelStates might be able to do what you want pretty quickly:

Message 5 of 12

infoXFJXM
Explorer
Explorer

Thank you for the help. It worked very well. If you know how to do it, it's really easy.
Can you help me how I can convert the individual model states to DXF files?

0 Likes
Message 6 of 12

J-Camper
Advisor
Advisor

Are looking for an export of the cut face as a 2D sketch?  Or do you need a 3D Object in AutoCAD?

0 Likes
Message 7 of 12

infoXFJXM
Explorer
Explorer

That's right. I need the component as a 2D sketch for further processing.

0 Likes
Message 8 of 12

J-Camper
Advisor
Advisor
Accepted solution

Create a Sketch on the same plane as the first one and project the cut geometry.  Name the sketch "ExportThisSketch" and run this rule:

 

Dim pDoc As PartDocument = TryCast(ThisApplication.ActiveDocument, PartDocument)
If pDoc Is Nothing Then Logger.Debug("Not Run In Part Document") : Exit Sub

If pDoc.FullFileName Is Nothing Then MessageBox.Show("Please save this file before running rule.")

Dim ExportSketch As PlanarSketch
Try
	ExportSketch = TryCast(pDoc.ComponentDefinition.Sketches.Item("ExportThisSketch"), PlanarSketch)
Catch
	MessageBox.Show("Please Create a 2D sketch that you want to export and name it: ""ExportThisSketch"".")
	Exit Sub
End Try

Dim DXFfilename As String 

Dim sysPath As System.IO.Path
DXFfilename = sysPath.GetDirectoryName(pDoc.FullFileName)
DXFfilename = sysPath.Combine(DXFfilename, sysPath.GetFileNameWithoutExtension(pDoc.FullFileName) & "_DXF_Exports")

If Not System.IO.Directory.Exists(DXFfilename) Then System.IO.Directory.CreateDirectory(DXFfilename)

Dim AllModelStates As ModelStates = pDoc.ComponentDefinition.ModelStates
For Each ms As ModelState In AllModelStates
	If ms.Name = String.Empty Then Continue For
	If ms IsNot AllModelStates.ActiveModelState Then ms.Activate

	Call ExportSketch.DataIO.WriteDataToFile("DXF", System.IO.Path.Combine(DXFfilename, ms.Name & ".dxf"))
Next

 

Here is an example of me setting it up:

You should end up with a folder in the same location as your part file with all the exported sketches.  It may take a while for all 300.

Let me know if you have any questions, or run into any issues.

 
0 Likes
Message 9 of 12

infoXFJXM
Explorer
Explorer

The rule works, but the numbers are not displayed correctly. saving the individual disks as DXF works, but unfortunately not with the rule. I have uploaded the components and a picture of the plate 179.
Alternatively, you could also store the individual model states in a DWG and then save them. 
Or is that not possible?

0 Likes
Message 10 of 12

bradeneuropeArthur
Mentor
Mentor

Actually there is no code needed. 

You can use Inventor I-part features to do this.

bradeneuropeArthur_2-1738521148233.png

 

bradeneuropeArthur_1-1738521121816.png

 

bradeneuropeArthur_0-1738521045398.png

 

See attachment

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 11 of 12

J-Camper
Advisor
Advisor
Accepted solution

It looks like you chose to project the face instead of choosing the "Project Cut Edges" option.  This led to bad updates as the face geometry changes.  Please remake the sketch using an origin plan and the "Project Cut Edges" option:

0 Likes
Message 12 of 12

infoXFJXM
Explorer
Explorer

Now everything has worked out. Thank you for the help and support.

0 Likes