Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic to change sheet name in drawing

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
deffysalfauzi
607 Views, 14 Replies

ilogic to change sheet name in drawing

Hi, help me. I would like to change my sheet name to be sequentially numbers as shown below. Thanks.

 

FYI,
Nomenclature :
RTU-385-001 - 385-Filter Support BT_Top 2:1

 

Note :
RTU-385 = .ipt > iproperties > project > stock number

<space>-<space> = separator
001,002,003,.... = sequentially numbers as sheet number (3 digit)
385-Filter Support BT_Top 2 = .ipt > iproperties > project > part number
:1,2,3,.... = sheet number

 

Screenshot 2022-11-05 204139.png

14 REPLIES 14
Message 2 of 15

Via I-logic vba or vb.net?

 

Via I-logic:

Public Sub main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		sht.Name = c1 & "-" & "00" & c2 & c3 '& ":" & c2
	Next
	
	
End Sub

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 3 of 15

Wow thanks very much. How about 3 digit number, start from 001 to 999. Likes this one :

 

RTU-385-001

....

RTU-385-008

RTU-385-009

RTU-385-010

....

RTU-385-999

Message 4 of 15

Hi,
Is the rest of the code fine for you, only the digits from 001 to 999!?

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 5 of 15

is this what you need then?

Public Sub Main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		
		If c2<999 Then
			
			If c2<99 Then
				If c2<10 Then
			
		sht.Name = c1 & "-" & "00" & c2 & c3 '& ":" & c2
		
		End If
				Else
			
		sht.Name = c1 & "-" & "0" & c2 & c3 '& ":" & c2
		
		End If
			Else
		sht.Name = c1 & "-" & "" & c2 & c3 '& ":" & c2
		
		End If
	Next
	
	
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 6 of 15


@bradeneuropeArthur wrote:

Via I-logic vba or vb.net?

 

Via I-logic:

Public Sub main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		sht.Name = c1 & "-" & "00" & c2 & c3 '& ":" & c2
	Next
	
	
End Sub

 


Screenshot 2022-11-06 223829.png

ilogic from sheet 1 to 15, different from the goal likes this :

RTU-385-001 - 385-Filter Support BT_Top 2:1

....

RTU-385-008

RTU-385-009

RTU-385-010

....

RTU-385-999

 

Note :
RTU-385 = stock number

<space>-<space> = separator
001,002,...,099,...,999 = sequentially numbers same as sheet number (3 digit)
385-Filter Support BT_Top 2 = part number
:1,2,3,.... = sheet number

 

Message 7 of 15


@bradeneuropeArthur wrote:

is this what you need then?

Public Sub Main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		
		If c2<999 Then
			
			If c2<99 Then
				If c2<10 Then
			
		sht.Name = c1 & "-" & "00" & c2 & c3 '& ":" & c2
		
		End If
				Else
			
		sht.Name = c1 & "-" & "0" & c2 & c3 '& ":" & c2
		
		End If
			Else
		sht.Name = c1 & "-" & "" & c2 & c3 '& ":" & c2
		
		End If
	Next
	
	
End Sub

result from ilogic :

kode2.png

can you change the code.

 

***Sorry, my English is not good enough

 

Message 8 of 15

This will finally do the trick:

Public Sub Main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		
		
		
			
		If c2>0 And c2<9 Then
		sht.Name = c1 & "-" & "00" & c2 & c3 '& ":" & c2
	ElseIf c2>99 And c2 <999
		sht.Name = c1 & "-" & "" & c2 & c3 '& ":" & c2
	ElseIf c2>9 And c2<99
		sht.Name = c1 & "-" & "0" & c2 & c3 '& ":" & c2
	End If

		
		
			
	Next
	
	
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 9 of 15


@bradeneuropeArthur wrote:

This will finally do the trick:

 

 

Public Sub Main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		
		
		
			
		If c2>0 And c2<9 Then
		sht.Name = c1 & "-" & "00" & c2 & c3 '& ":" & c2
	ElseIf c2>99 And c2 <999
		sht.Name = c1 & "-" & "" & c2 & c3 '& ":" & c2
	ElseIf c2>9 And c2<99
		sht.Name = c1 & "-" & "0" & c2 & c3 '& ":" & c2
	End If

		
		
			
	Next
	
	
End Sub

 

 


code3.png

Sheet:9 ?

 

change to this ?

ElseIf c2>=9 And c2<99
Message 10 of 15

we come closer:

Public Sub Main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		If c2>0 And c2<10 Then
		sht.Name = c1 & "-" & "00" & c2 & c3 '& ":" & c2
	ElseIf c2>99 And c2 <1000
		sht.Name = c1 & "-" & "" & c2 & c3 '& ":" & c2
	ElseIf c2>9 And c2<100
		sht.Name = c1 & "-" & "0" & c2 & c3 '& ":" & c2
	End If

		
		
			
	Next
	
	
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 11 of 15

code4.png

can you give a (space)-(space) like this " - " without quote between like this c2 & c3

c2 & " - " & c3

 

		sht.Name = c1 & "-" & "00" & c2 & c3 '& ":" & c2
	ElseIf c2>99 And c2 <1000
		sht.Name = c1 & "-" & "" & c2 & c3 '& ":" & c2
	ElseIf c2>9 And c2<100
		sht.Name = c1 & "-" & "0" & c2 & c3 '& ":" & c2

 

Message 12 of 15

Public Sub Main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		If c2>0 And c2<10 Then
		sht.Name = c1 & " - " & "00" & c2 & " - " & c3 '& ":" & c2
	ElseIf c2>99 And c2 <1000
		sht.Name = c1 & " - " & "" & c2& " - " & c3 '& ":" & c2
	ElseIf c2>9 And c2<100
		sht.Name = c1 & " - " & "0" & c2& " - " & c3 '& ":" & c2
	End If
		
	Next
	
	
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 13 of 15

kode4edit.png

 
Public Sub Main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		If c2>0 And c2<10 Then
		sht.Name = c1 & "-" & "00" & c2 & " - " & c3 '& ":" & c2
	ElseIf c2>99 And c2 <1000
		sht.Name = c1 & "-" & "" & c2 & " - " & c3 '& ":" & c2
	ElseIf c2>9 And c2<100
		sht.Name = c1 & "-" & "0" & c2 & " - " & c3 '& ":" & c2
	End If
			
	Next
	
End Sub
Message 14 of 15


@bradeneuropeArthur wrote:

we come closer:

Public Sub Main
	
	Dim a As Inventor.DrawingDocument = ThisDrawing.Document
	Dim sht As Inventor.Sheet
	Dim shts As Inventor.Sheets
	Dim c2 As Integer = 0
	For Each sht In a.Sheets
		c2=c2+1
		Dim d As Inventor.Document = sht.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument

		Dim c1 As String = d.PropertySets.Item(3).Item("stock number").Value
		
		Dim c3 As String = d.PropertySets.Item(3).Item( "part number").Value
		
		If c2>0 And c2<10 Then
		sht.Name = c1 & "-" & "00" & c2 & c3 '& ":" & c2
	ElseIf c2>99 And c2 <1000
		sht.Name = c1 & "-" & "" & c2 & c3 '& ":" & c2
	ElseIf c2>9 And c2<100
		sht.Name = c1 & "-" & "0" & c2 & c3 '& ":" & c2
	End If

		
		
			
	Next
	
	
End Sub

Based on this code, I changed and added a space between C2 and C3. thanks

 

		sht.Name = c1 & "-" & "00" & c2 & " - " & c3 '& ":" & c2
	ElseIf c2>99 And c2 <1000
		sht.Name = c1 & "-" & "" & c2 & " - " & c3 '& ":" & c2
	ElseIf c2>9 And c2<100
		sht.Name = c1 & "-" & "0" & c2 & " - " & c3 '& ":" & c2
Message 15 of 15

Thank you very much. Exported to AutoCAD so it looks like this.

THANKS.png

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report