Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
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: 

run rule in drawing

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
sjoerd.van.der.eerden
497 Views, 7 Replies

run rule in drawing

hi, 

I want to run a rule in a drawing from my master assambly. 

is this possible or not?

7 REPLIES 7
Message 2 of 8

Are you using Vault Professional or Workgroup?

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 8

There are likely multiple possible ways to do this, but here is a somewhat simple way, if you don't mind specifying full file path of the drawing within the code.

Dim oFile As String = "C:\Temp\MyDrawing.idw"
Dim oDrawDoc As Document = ThisApplication.Documents.Open(oFile, True) 'True = visible
Dim oNameOfRuleInDoc As String = "MyRuleName"
Dim oRuleInDoc As iLogicRule = iLogicVb.Automation.GetRule(oDrawDoc, oNameOfRuleInDoc)
If IsNothing(oRuleInDoc) Then
	MsgBox("The specified rule was not found in specified document.", vbCritical, "iLogic")
	Return
End If
iLogicVb.Automation.RunRuleDirect(oRuleInDoc)
'or
'iLogicVb.Automation.RunRule(oDrawDoc, oNameOfRuleInDoc)
If oDrawDoc.RequiresUpdate Then oDrawDoc.Update2(True)
If oDrawDoc.Dirty Then oDrawDoc.Save2

If this doesn't suit your needs, then please be more specific and detailed about your situation and needs.  We may be able to do this in several other ways.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 8

hi, 

the drawing (dwg file) is already open when I want to run the rule. also the drawing and the assambly from which I'm trying to run the rule are in the same folder. 

Message 5 of 8

Dim oDoc As Document = ThisDoc.Document
Dim strFolder As String = System.IO.Path.GetDirectoryName(oDoc.FullFileName)
Dim strFileName As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
Dim strDrawname As String = strFolder & "\" & strFileName & ".dwg"
MsgBox(strDrawname)
Dim drawdoc As DrawingDocument = ThisApplication.Documents.Open(strDrawname, True)
drawdoc.activate
iLogicVb.RunRule(drawdoc, "ruleName")
drawdoc.update
Message 6 of 8

sjoerdvandereerden_0-1670925506806.png

seems odd that it can't vind it because it's right there. 

 

Message 7 of 8

Apologies, somehow the snippet is different then when doing this:

 

Dim oDoc As Document = ThisDoc.Document
Dim strFolder As String = System.IO.Path.GetDirectoryName(oDoc.FullFileName)
Dim strFileName As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
Dim strDrawname As String = strFolder & "\" & strFileName & ".dwg"
Dim drawdoc As Document = ThisApplication.Documents.Open(strDrawname, True)
drawdoc.activate

Dim iLogicAuto = iLogicVb.Automation
iLogicAuto.RunRule(drawdoc, "ruleName")
drawdoc.update
Message 8 of 8

thanks, this works great. 

you're truly a hero!

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

Post to forums  

Autodesk Design & Make Report