iLogic - chceck if parts in assembly has a drawing

iLogic - chceck if parts in assembly has a drawing

Milan_Nosil
Advocate Advocate
2,219 Views
20 Replies
Message 1 of 21

iLogic - chceck if parts in assembly has a drawing

Milan_Nosil
Advocate
Advocate

Hello,

Can you help me please with creating the rule running in assembly? This rule should check that all parts and subassemblies have a drawings created. If they have a drawing, the rule creates a new user iProperty "Drawing" with a value "x" in the model (in a parts and subassemblies).

 

I have a rule that finds all drawings and creates pdf files (can't be publicly distributed, I would send it on request). Unfortunately, I can't edit the rule to modify models and create properties, and not to create a pdf.

 

Thank you very much for any advice.

MN

0 Likes
Accepted solutions (1)
2,220 Views
20 Replies
Replies (20)
Message 2 of 21

bradeneuropeArthur
Mentor
Mentor

I think this is only possible if:

  • You are using vault and whereUsed functionlity
  • Or if the files are always on a fix location. and use a routine to check these paths.

 

Regards,

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 3 of 21

fullevent
Advisor
Advisor

Hi @Milan_Nosil,

 

i think @bradeneuropeArthur is right.
I have a rule where you can select a Occurrence. The rule will check if there is a .idw or .dwg within the project.

 

Just copy the code in an iLogic rule. Maybe this will help you.

 

Sub Main
	
	Dim oOcc As ComponentOccurrence
	oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Komponente auswählen..")
	
    Dim oDoc As Document 
    oDoc = oOcc.Parent.Parent  
     
    ' Call the function to get the drawing.  
    Dim drawingFilename As String 
    drawingFilename = FindDrawingFile(oDoc) 
    
    ' Display the result. 
    If drawingFilename <> "" Then 
        MsgBox ("The drawing for """ & oDoc.FullFileName & """ was found: " & vbCr & drawingFilename )
    Else 
        MsgBox ("No drawing was found for """ & oDoc.FullFileName & """" )
    End If 
End Sub

Private Function FindDrawingFile(PartOrAssemblyDoc As Document) 
    Dim fullFilename As String 
    fullFilename = PartOrAssemblyDoc.FullFileName 
    Dim path As String 
    path = Left$(fullFilename, InStrRev(fullFilename, "\")) 
    Dim filename As String 
    filename = Right$(fullFilename, Len(fullFilename) - InStrRev(fullFilename, "\")) 
    filename = Left$(filename, InStrRev(filename, ".")) & "dwg" 
    Dim drawingFilename As String 
    drawingFilename = ThisApplication.DesignProjectManager.ResolveFile(path, filename) 
    If drawingFilename = "" Then 
        filename = Left$(filename, InStrRev(filename, ".")) & "idw" 
        drawingFilename = ThisApplication.DesignProjectManager.ResolveFile(path, filename) 
        If drawingFilename <> "" Then 
            FindDrawingFile = drawingFilename 
        Else 
            FindDrawingFile = "" 
        End If 
    Else 
        FindDrawingFile = drawingFilename 
    End If 
End Function

source: https://modthemachine.typepad.com/my_weblog/2016/01/open-drawing-from-a-part-or-assembly.html 

 

good luck 😊


Aleksandar Krstic
Produkt- und Projektmanager

Message 4 of 21

Milan_Nosil
Advocate
Advocate

Thank you very much for advices @bradeneuropeArthur @fullevent .

 

Yes, I use Vault Basic.

 

The whole problem is that I need to mark which parts have their drawing (in the BOM of a main assembly drawing). I know where to find out, but I need to get the information into a printed drawing.

Thank you.

0 Likes
Message 5 of 21

bradeneuropeArthur
Mentor
Mentor

Put it in the Partslist!

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 6 of 21

bradeneuropeArthur
Mentor
Mentor

I have a very simple solution for it.

 

Keep reading....

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 7 of 21

bradeneuropeArthur
Mentor
Mentor

For my company I have written an add in that will fill in a user property to the part or assembly "Drawing" yes or No.

 

In the partslist we have added a column to represent this value Drawing Yes or No.

 

Regards,

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 8 of 21

Milan_Nosil
Advocate
Advocate

YES - this is it, can it be solved by iLogic rule?

0 Likes
Message 9 of 21

bradeneuropeArthur
Mentor
Mentor

Yes!

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 10 of 21

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Public Sub main()

Dim a As Application
Set a = ThisApplication

Dim b As DrawingDocument
Set b = a.ActiveDocument

Dim mdl As Document

Dim c As DrawingView
Set c = b.ActiveSheet.DrawingViews(1)

Dim d As DocumentDescriptor
Set d = c.ReferencedDocumentDescriptor

Set mdl = d.ReferencedDocument


'Dim prp As Property
On Error Resume Next

Call mdl.PropertySets.Item(4).Add("Yes", "Drawing")


End Sub

for ilogic:

Public Sub main()

Dim a As Application
a = ThisApplication

Dim b As DrawingDocument
b = a.ActiveDocument

Dim mdl As Document

Dim c As DrawingView
c = b.ActiveSheet.DrawingViews(1)

Dim d As DocumentDescriptor
d = c.ReferencedDocumentDescriptor

mdl = d.ReferencedDocument

On Error Resume Next

Call mdl.PropertySets.Item(4).Add("Yes", "Drawing")


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

WCrihfield
Mentor
Mentor

Here is probably the most simple way to check if any model has a drawing, using iLogic code.

Dim oFileName As String = ThisDoc.FileName(False)
Dim oPath As String = ThisDoc.Path
If System.IO.File.Exists(oPath & "\" & oFileName & ".idw") = True Then
	MsgBox("Yes. This model has a Drawing file.")
	'Do what you want
ElseIf System.IO.File.Exists(oPath & "\" & oFileName & ".idw") = False Then
	MsgBox("No. This model does not have a Drawing file.")
	'Do what you want
End If

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 12 of 21

bradeneuropeArthur
Mentor
Mentor

Hi @WCrihfield 

 

This only works if the structure is always this way! (in the same directory)

If this is the case, then this is of course the easiest way to check.

But how to implement this is the BOM or Partslist?

 

Regards,

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 13 of 21

WCrihfield
Mentor
Mentor

Yes, I know.  I just meant that method of using 'System.IO.File.Exists()' to see if a file exists.

If you can get the file name by whatever means necessary, and you know the procedure for where its drawing would have been saved to, then you can use this method to see if the file exists.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 14 of 21

Milan_Nosil
Advocate
Advocate

Thank you very much @bradeneuropeArthur , @WCrihfield and @fullevent 

 

Unfortunately, the rules from @bradeneuropeArthur doesn't work for me (the rule does nothing), but that is exactly what I need 🙂

 

Thank you.

 

0 Likes
Message 15 of 21

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Are you running the code from within a drawing-file, as needed?

 

Regards,

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 16 of 21

Milan_Nosil
Advocate
Advocate

Hi,

 

Maybe I'm doing something wrong. I attach the screencast for sure.

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0 Likes
Message 17 of 21

fullevent
Advisor
Advisor

Hi

 

i think you got the iProperty in this model (iam)..

2020-02-17 09_00_59-Window.png

 

The rule doesnt effect the parts/components the deeper levels..

 

Try running the rule in this drawing (drawing of the part):

2020-02-17 09_05_21-Window.png

 

regars


Aleksandar Krstic
Produkt- und Projektmanager

Message 18 of 21

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Maybe the ipt file is Read-only.

For me it works!

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 19 of 21

Milan_Nosil
Advocate
Advocate

Yes, it works! 😁 Thank you very much. That's exactly it.

 

Right now I have to add it to the template and run it automatically before saving the drawing document. Can I run it in bulk?

 

Can I run a rule to search parts in the entire assembly and trigger this new rule in their drawings?

0 Likes
Message 20 of 21

bradeneuropeArthur
Mentor
Mentor
Public Sub Main()

Dim a As Inventor.Application
a = ThisApplication

Dim b As DrawingDocument
b = a.ActiveDocument

Dim mdl As Document
For Each b In a.Documents
	Dim c As DrawingView
c = b.ActiveSheet.DrawingViews(1)

Dim d As DocumentDescriptor
d = c.ReferencedDocumentDescriptor

mdl = d.ReferencedDocument

On Error Resume Next

Call mdl.PropertySets.Item(4).Add("Yes", "Drawing2")
Next
	

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

0 Likes