run rule in drawing

run rule in drawing

sjoerd.van.der.eerden
Contributor Contributor
794 Views
7 Replies
Message 1 of 8

run rule in drawing

sjoerd.van.der.eerden
Contributor
Contributor

hi, 

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

is this possible or not?

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

bradeneuropeArthur
Mentor
Mentor
Are you using Vault Professional or Workgroup?

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 8

WCrihfield
Mentor
Mentor

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

sjoerd.van.der.eerden
Contributor
Contributor

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. 

0 Likes
Message 5 of 8

Cadkunde.nl
Collaborator
Collaborator
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
0 Likes
Message 6 of 8

sjoerd.van.der.eerden
Contributor
Contributor

sjoerdvandereerden_0-1670925506806.png

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

 

0 Likes
Message 7 of 8

Cadkunde.nl
Collaborator
Collaborator
Accepted solution

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
0 Likes
Message 8 of 8

sjoerd.van.der.eerden
Contributor
Contributor

thanks, this works great. 

you're truly a hero!

0 Likes