Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: Anonymous

Ok here's the whole spill :expressionless_face:

 

I have rule that does the stuff i need to do. From a drawing:

  1. checks to make sure the referenced model matches the drawing
  2. opens the referenced model and saves. This will trigger two external rules
    1. updated everything to make sure the dxf will be accurate.
    2. creates the dxf.
    3. Closes the model and goes back to the idw

PDF's the drawings.

This is the code for the  checking portion of the rule

Imports System.Threading.Tasks
Dim timeout = 1.5 ' secs
Dim msg As New Form() With { .Enabled = False }

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim view As DrawingView = sheet.DrawingViews.Item(1)
Dim refDoc As Document = ThisApplication.Documents.Open(view.ReferencedFile.FullFileName)
'Dim addin As ApplicationAddIn 'xxxxxx'Dim iLogicAuto As Object = addin.Automation'xxxxxx

'oDoc = ThisDoc.FileName(False) 'without extension'xxxxxx
attachedModel = ThisDoc.Path & "\" & IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
PreModel = ThisDoc.ChangeExtension(".ipt")
intendedModel = Replace(PreModel,"-1_","-0_")
'MessageBox.Show("attachedModel = " & attachedModel, "iLogic")

If attachedModel = intendedModel Then
        Task.Delay(TimeSpan.FromSeconds(timeout)).ContinueWith(
        Sub(t) 
            msg.Close() 
        End Sub ,
    TaskScheduler.FromCurrentSynchronizationContext())
    MessageBox.Show(msg,"Model/Drawing Matches", "iLogic")
    refDoc.Save()
    refDoc.Close()
'    Parameter("d0") = 1.2

Else 
    MessageBox.Show("The drawing has the wrong model attached", "iLogic")
    Return 
End If

 This is the code that calls the model and pdf's after it is done.

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim view As DrawingView = sheet.DrawingViews.Item(1)
Dim refDoc As Document = ThisApplication.Documents.Open(view.ReferencedFile.FullFileName)

iLogicVb.RunExternalRule("ModelMatchDrawing")
'refDoc.Save()'refDoc.Close()
iLogicVb.RunExternalRule("PDFit")