add rule in multiple documents

add rule in multiple documents

johan.degreef
Advisor Advisor
548 Views
5 Replies
Message 1 of 6

add rule in multiple documents

johan.degreef
Advisor
Advisor

Add rule (external or from a dwg) to all existing dwg's or all open documents, and set it to an event trigger.

 

I have this new rule that I want to add to several documents. Is there a way to so this without openening all existing documents 1 by one? If possible it should be set to run on certain events too.

 

BR, Johan

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Accepted solutions (1)
549 Views
5 Replies
Replies (5)
Message 2 of 6

bradeneuropeArthur
Mentor
Mentor

Hi Johan,

 

This is one of the disadvantages of I logic and vba with build in macro's.

I can only advice you to start programming add-ins for Inventor.

I have seen some of your coding and personally I think you are able to learn this too!

With add ins you have much more flexibility and you have no build in coding that needs to be updated for each document!

There are possibilities too add rules to each document I think.

We also can try to make it possible with an update of the lately programmed Drawing list Tool!

 

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 6

bradeneuropeArthur
Mentor
Mentor

Could you give me the code that needs to be added?

Otherwise:

Put your code as text on the place of "YOUR CODE"

Dim a As Inventor.DrawingDocument
Dim iLogicAuto = iLogicVb.Automation

For Each a In ThisApplication.Documents
	a.Activate
	iLogicAuto.AddRule(ThisApplication.ActiveDocument,"Test", "YOUR CODE")
	Next

 

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

bradeneuropeArthur
Mentor
Mentor

Why are you not using an external rule and let this run on save or other event for all drawings!

bradeneuropeArthur_0-1615712416980.png

 

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

johan.degreef
Advisor
Advisor

All I have code-wise are snippets that I found or from other people, so no programmer in me (yet)

I can do this with an external rule, but still need to add the event trigger to all existing drawings.

 

Maybe it is time to start learning code 🙂 Any good starting pointers?

Where should I begin with creating those add ins.

 

Knipsel.JPG

 

 

 

On Error Resume Next
'https://www.cadlinecommunity.co.uk/hc/en-us/articles/203292761
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oPromptEntry

Dim oCurrentSheet
oCurrentSheet = oDoc.ActiveSheet.Name

i = 1
For Each oSheet In oDoc.Sheets
  'i = i+1
  ThisApplication.ActiveDocument.Sheets.Item(i).Activate
       oTitleBlock=oSheet.TitleBlock
    oTextBoxes=oTitleBlock.Definition.Sketch.TextBoxes
    For Each oTextBox In oTitleBlock.Definition.Sketch.TextBoxes
		
    Select oTextBox.Text
		
        Case "<PTN_DRAWING>"
            oPromptEntry  =  oTitleBlock.GetResultText(oTextBox)
            iProperties.Value("Custom", "PTN_DRAWING")=oPromptEntry
        Case "<PTN_REVISION>"
            oPromptEntry  =  oTitleBlock.GetResultText(oTextBox)
            iProperties.Value("Custom", "PTN_REVISION")=oPromptEntry
        Case "<PTN_TITLE_EN>"
            oPromptEntry  =  oTitleBlock.GetResultText(oTextBox)
            iProperties.Value("Custom", "PTN_TITLE_EN")=oPromptEntry
        Case "<PTN_DESCRIPTION_EN>"
            oPromptEntry  =  oTitleBlock.GetResultText(oTextBox)
            iProperties.Value("Custom", "PTN_DESCRIPTION_EN")=oPromptEntry
        Case "<PTN_CLIENT>"
            oPromptEntry  =  oTitleBlock.GetResultText(oTextBox)
            iProperties.Value("Custom", "PTN_CLIENT") = oPromptEntry
        Case "<PTN_PROJECTNR>"
            oPromptEntry  =  oTitleBlock.GetResultText(oTextBox)
            iProperties.Value("Custom", "PTN_PROJECTNR")=oPromptEntry
        Case "<PTN_COMMENTS>"
            oPromptEntry  =  oTitleBlock.GetResultText(oTextBox)
            iProperties.Value("Custom", "PTN_COMMENTS")=oPromptEntry

			

    End Select
    Next
Next

 

 

 

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Message 6 of 6

bradeneuropeArthur
Mentor
Mentor
Accepted solution

You can do that in the application.

No need to do that per drawing.

See my screenshot.

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