hi,
I want to run a rule in a drawing from my master assambly.
is this possible or not?
Solved! Go to Solution.
Solved by Cadkunde.nl. Go to Solution.
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 !
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
(Not an Autodesk Employee)
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.
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
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
Can't find what you're looking for? Ask the community or share your knowledge.