[iLogic] How to set sheet names to drawing and model iproperties?

[iLogic] How to set sheet names to drawing and model iproperties?

Tom_VS
Participant Participant
926 Views
7 Replies
Message 1 of 8

[iLogic] How to set sheet names to drawing and model iproperties?

Tom_VS
Participant
Participant

Hello,

 

To save time I want to set my sheet names to display as: "drawing iproperty (company)"-"model iproperty (part number)".

 

Example: The drawing iproperty under company is set as "CoolCompany". The model part number of the first drawing in the first sheet is set as "L0201". After running an iLogic rule, the first sheet name would read out as: CoolCompany-L0201

 

While looking through this forum, I found part of the solution as follows:

 

SyntaxEditor Code Snippet

Sub Main
    If TypeOf ThisDoc.Document Is DrawingDocument Then
        Dim dwgDoc As DrawingDocument = ThisDoc.Document
        For Each dwgSheet As Sheet In dwgDoc.Sheets
            If dwgSheet.DrawingViews.Count > 0 Then
                modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName
                modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
                prtNumber = modelDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(5).Value
                If Not String.IsNullOrEmpty(prtNumber) Then
                    dwgSheet.Name = prtNumber
                End If
            End If
        Next
    End If
End Sub

 

This however, only grabs the iproperty from the model. It lacks the drawing iproperty I would like to include. I tried mixing and matching various solutions on this forum, but my programming knowledge is abysmal. I couldn't find a solution. Can anyone help fill in the missing code?

 

Thanks in advance,

Tom

 

P.S.: great forum and great contributors. It helped me a ton so far.

 

 

0 Likes
Accepted solutions (1)
927 Views
7 Replies
Replies (7)
Message 2 of 8

bradeneuropeArthur
Mentor
Mentor
Sub Main()
    If TypeOf ThisDoc.Document Is DrawingDocument Then
    
    comp = a.ActiveDocument.PropertySets.Item(2).Item("company")
        Dim dwgDoc As DrawingDocument = ThisDoc.Document
        For Each dwgSheet As Sheet In dwgDoc.Sheets
            If dwgSheet.DrawingViews.Count > 0 Then
                modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName
                modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
                prtNumber = modelDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(5).Value
                If Not String.IsNullOrEmpty(prtNumber) Then
                    dwgSheet.Name = comp & "-" & prtNumber
                End If
            End If
        Next
    End If
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

Message 3 of 8

Tom_VS
Participant
Participant

Thanks for the reply.

 

I tried your code but I get an error:

Error on Line 4 : a has not been declared. The item may not be accessible due to the associated security level. 

0 Likes
Message 4 of 8

bradeneuropeArthur
Mentor
Mentor

Mistake:

 

dim a as application

a = thisapplication

 

put this in it/…..

 

OR:

Sub Main()
    If TypeOf ThisDoc.Document Is DrawingDocument Then
    
    comp = ThisDoc.Document .PropertySets.Item(2).Item("company")
        Dim dwgDoc As DrawingDocument = ThisDoc.Document
        For Each dwgSheet As Sheet In dwgDoc.Sheets
            If dwgSheet.DrawingViews.Count > 0 Then
                modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName
                modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
                prtNumber = modelDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(5).Value
                If Not String.IsNullOrEmpty(prtNumber) Then
                    dwgSheet.Name = comp & "-" & prtNumber
                End If
            End If
        Next
    End If
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

Message 5 of 8

Tom_VS
Participant
Participant

Thanks for the correction.

 

However, another error popped up: Operator & is not defined for Property type and string -.

0 Likes
Message 6 of 8

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Sub Main()
    If TypeOf ThisDoc.Document Is DrawingDocument Then
    
    comp = ThisDoc.Document .PropertySets.Item(2).Item("company")
        Dim dwgDoc As DrawingDocument = ThisDoc.Document
        For Each dwgSheet As Sheet In dwgDoc.Sheets
            If dwgSheet.DrawingViews.Count > 0 Then
                modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName
                modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
                prtNumber = modelDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(5).Value
                If Not String.IsNullOrEmpty(prtNumber) Then
                    dwgSheet.Name = comp.value & "-" & prtNumber
                End If
            End If
        Next
    End If
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

Message 7 of 8

Tom_VS
Participant
Participant

Awesome, worked like a charm!

0 Likes
Message 8 of 8

bradeneuropeArthur
Mentor
Mentor
Your thanks are appreciated.
between the jobs there were some mismatches.
Sorry for that...

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