Section & Detail View Label

Section & Detail View Label

Talayoe
Collaborator Collaborator
2,630 Views
12 Replies
Message 1 of 13

Section & Detail View Label

Talayoe
Collaborator
Collaborator

Good afternoon all,

 

I am working with a large drawing package (for me at least) that is 36 pages long, 25 or so different parts for the build.

 

What I dont care for is that the detail view labels are incrementing thru the entire drawing package and I would rathe have it sheet by sheet, if possible. 

 

Example:

Drawing Sheet 1: I create 3 section views, it auto labels then A-A, B-B, C-C, ect.

Drawing Sheet 2: I create a single (or more) section views it currently labels them D-D, ect whereas I would like it to start over at A-A.

 

Is this possible? 

 

For the sake of the package by the time I will be done with it I will have so many section views/detail views labels that I will be in CZ-CZ likely.

 

Tks!

-Randy

----------------------
Inventor 2017 PDS
0 Likes
Accepted solutions (1)
2,631 Views
12 Replies
Replies (12)
Message 2 of 13

SharkDesign
Mentor
Mentor

You could probably write iLogic code to do this, but there isn't a standard command for this.

 

 

  Inventor Certified Professional
0 Likes
Message 3 of 13

Talayoe
Collaborator
Collaborator

Hi James,

 

I did find another post with an iLogic code to rename them incrementally thru the entire drawing. Works well, keeps them in order, but still on the increment status. Not a huge deal, but it would still be nice to have broken up by drawing, like revision numbers can be. 

 

Thanks for the quick reply/thot!

-Randy

----------------------
Inventor 2017 PDS
0 Likes
Message 4 of 13

jtylerbc
Mentor
Mentor

If you make each sheet as a separate drawing file, they will each have their own labeling sequence starting at A-A.

 

You get one sequence per drawing file, so other than manual relabeling (or iLogic/VBA automating the manual relabeling process), breaking it up into individual files is the only way to get what you want.

0 Likes
Message 5 of 13

theo.bot
Collaborator
Collaborator
Accepted solution

This Rule will rename all Section, Detail, Auxiliary and Projected views with a broken alingment. By default the rule will restart with the view names for each sheet. But for those who would like to have this for the entire document, simply change the RestartperSheet to False.

 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

Dim oSheet As Sheet
Dim oView As DrawingView
Dim oLabel As String
Dim RestartperSheet As Boolean

'Set this value to False if you want te rename views for all sheets
'Set this value to True if you want to rename views per sheet
RestartperSheet = True
'Set Start Label
oLabel = "A"

For Each oSheet In oDoc.Sheets
	'If True Set label Start Value per sheet
	If RestartperSheet = True
		oLabel = "A"
	End If
	For Each oView In oSheet.DrawingViews
		Logger.Info(oView.ViewType & " " & oView.Name)

		Select Case oView.ViewType
			Case kSectionDrawingViewType
				'Set view name to Label
				oView.Name = oLabel
				'Set Label to next character
				oLabel = Chr(Asc(oLabel) + 1)
			Case kAuxiliaryDrawingViewType
				'Set view name to Label
				oView.Name = oLabel
				'Set Label to next character
				oLabel = Chr(Asc(oLabel) + 1)
			Case kDetailDrawingViewType
				'Set view name to Label
				oView.Name = oLabel
				'Set Label to next character
				oLabel = Chr(Asc(oLabel) + 1)
			Case kProjectedDrawingViewType
				If oView.Aligned = False Then
					'Set view name to Label
					oView.Name = oLabel
					'Set Label to next character
					oLabel = Chr(Asc(oLabel) + 1)
				End If
		End Select
	Next
Next

 

Message 6 of 13

Talayoe
Collaborator
Collaborator

Thank you so much, that is EXACTLY what I was looking for! 🙂

-Randy

----------------------
Inventor 2017 PDS
Message 7 of 13

matthew.wrightSCX
Contributor
Contributor

This is great, however be aware that it will need tweaking to avoid the use of letters "I" & "O" as part of drawing standards.

0 Likes
Message 8 of 13

theo.bot
Collaborator
Collaborator

@matthew.wrightSCX ,

 

You're right, I should have added that 😉

 

here a new version that includes the check, if in the drawing standard "view Names" are enabled in the "apply to" section it will check the list.:

 

theobot_0-1639551541895.png

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

Dim oStyleM As DrawingStylesManager
oStyleM = oDoc.StylesManager

Dim oStandard As DrawingStandardStyle
oStandard = oStyleM.ActiveStandardStyle

Dim oSheet As Sheet
Dim oView As DrawingView
Dim oLabel As String
Dim RestartperSheet As Boolean

'Set this value to False if you want te rename views for all sheets
'Set this value to True if you want to rename views per sheet
RestartperSheet = False
'Set Start Label
oLabel = "A"


For Each oSheet In oDoc.Sheets
	'If True Set label Start Value per sheet
	If RestartperSheet = True
		oLabel = "A"
	End If
	For Each oView In oSheet.DrawingViews
		Logger.Info(oView.ViewType & " " & oView.Name)
		'Exclude Charater from standard style list
		If oStandard.ApplyExcludeCharactersToViewNames = True Then
			While oStandard.ExcludeCharacters.Contains(oLabel) = True
				oLabel = Chr(Asc(oLabel) + 1)
			End While
		End If
		Select Case oView.ViewType
			Case kSectionDrawingViewType
				'Set view name to Label
				oView.Name = oLabel
				'Set Label to next character
				oLabel = Chr(Asc(oLabel) + 1)
			Case kAuxiliaryDrawingViewType
				'Set view name to Label
				oView.Name = oLabel
				'Set Label to next character
				oLabel = Chr(Asc(oLabel) + 1)
			Case kDetailDrawingViewType
				'Set view name to Label
				oView.Name = oLabel
				'Set Label to next character
				oLabel = Chr(Asc(oLabel) + 1)
			Case kProjectedDrawingViewType
				If oView.Aligned = False Then
					'Set view name to Label
					oView.Name = oLabel
					'Set Label to next character
					oLabel = Chr(Asc(oLabel) + 1)
				End If
		End Select
	Next
Next

iLogicVb.UpdateWhenDone = True

 

Message 9 of 13

gflessasP4B6Q
Explorer
Explorer

Hey @theo.bot, I know that its been a few years since you wrote this.

I've started using this code and its very helpful, however I'm running into an issue where when it gets to the end of the alphabet, instead of going to AA, it uses characters like /, and [.

 

Is it possible to tweak your code to switch to AA, AB, AC, etc?

0 Likes
Message 10 of 13

daltonNYAW9
Advocate
Advocate

I had the same problem. Add the following function and replace these lines:
Link to solution 

 

Replace

oLabel = Chr(Asc(oLabel) + 1)

 With

oLabel = GetAlphaString(oLabel)

 

 The function increases the label value every time it is called

Public Function GetAlphaString(ByVal ColumnLetter As String) As String
	'convert to number
	For i = 1 To Len(ColumnLetter)
		AlphaNum = AlphaNum * 26 + (Asc(UCase(Mid(ColumnLetter, i, 1))) -64)
	Next

	AlphaNum = AlphaNum + 1

	'convert back to format
	Do While AlphaNum > 0
		AlphaNum = AlphaNum - 1
		GetAlphaString = ChrW(65 + AlphaNum Mod 26) & GetAlphaString
		AlphaNum = AlphaNum \ 26
	Loop
End Function

 

0 Likes
Message 11 of 13

jacobWN5VK
Explorer
Explorer

ignore this

0 Likes
Message 12 of 13

mathew_kenney
Explorer
Explorer

Hi there. I was looking to use the above code but with the change of using numbers for the detail views and letters for section, auxillary etc.

How would I do this? Thanks

0 Likes
Message 13 of 13

gho.ghorbani
Explorer
Explorer

Hi there
use this code

Sub Main()
    Dim oDoc As DrawingDocument
    oDoc = ThisDoc.Document

    Dim oStyleM As DrawingStylesManager
    oStyleM = oDoc.StylesManager

    Dim oStandard As DrawingStandardStyle
    oStandard = oStyleM.ActiveStandardStyle

    Dim oSheet As Sheet
    Dim oView As DrawingView
    Dim oLabel As String
    Dim RestartperSheet As Boolean

    ' Set this value to True to rename views per sheet, False for continuous labeling across all sheets
    RestartperSheet = True
    ' Set Start Label
    oLabel = "A"

    For Each oSheet In oDoc.Sheets
        ' Reset label to A for each sheet if RestartperSheet is True
        If RestartperSheet = True Then
            oLabel = "A"
        End If
        For Each oView In oSheet.DrawingViews
            Logger.Info(oView.ViewType & " " & oView.Name)
            ' Skip excluded characters for the current label
            If oStandard.ApplyExcludeCharactersToViewNames = True Then
                While oStandard.ExcludeCharacters.Contains(oLabel) = True
                    oLabel = GetNextLabel(oLabel, oStandard)
                End While
            End If
            Select Case oView.ViewType
                Case kSectionDrawingViewType
                    ' Set view name to Label
                    oView.Name = oLabel
                    ' Get next valid label
                    oLabel = GetNextLabel(oLabel, oStandard)
                Case kAuxiliaryDrawingViewType
                    ' Set view name to Label
                    oView.Name = oLabel
                    ' Get next valid label
                    oLabel = GetNextLabel(oLabel, oStandard)
                Case kDetailDrawingViewType
                    ' Set view name to Label
                    oView.Name = oLabel
                    ' Get next valid label
                    oLabel = GetNextLabel(oLabel, oStandard)
                Case kProjectedDrawingViewType
                    If oView.Aligned = False Then
                        ' Set view name to Label
                        oView.Name = oLabel
                        ' Get next valid label
                        oLabel = GetNextLabel(oLabel, oStandard)
                    End If
            End Select
        Next
    Next

    iLogicVb.UpdateWhenDone = True
End Sub

' Function to get the next valid label (A-Z, skipping excluded characters)
Function GetNextLabel(currentLabel As String, oStandard As DrawingStandardStyle) As String
    Dim nextLabel As String
    nextLabel = Chr(Asc(currentLabel) + 1)
    ' Ensure label stays within A-Z (ASCII 65-90)
    If Asc(nextLabel) > Asc("Z") Then
        nextLabel = "A" ' Reset to A if exceeding Z
    End If
    ' Skip excluded characters
    If oStandard.ApplyExcludeCharactersToViewNames = True Then
        While oStandard.ExcludeCharacters.Contains(nextLabel) = True
            nextLabel = Chr(Asc(nextLabel) + 1)
            If Asc(nextLabel) > Asc("Z") Then
                nextLabel = "A" ' Reset to A if exceeding Z
            End If
        End While
    End If
    GetNextLabel = nextLabel
End Function
0 Likes