The reason I asked for your existing ilogic rule is so I could get the answers to these questions below...
Where does the pdf file get saved..same folder as part/drawing? In our network, same folder for parts and drawings. And does anything get appended to its name (like revision?).. Yes, but they always share the same name.
Where does the dxf file get saved..same folder as part/drawing? Same as above. And does anything get appended to its name (like revision?).. Same as above.
Where does the step file get saved..same folder as part/drawing? Same as above. And does anything get appended to its name (like revision?).. Same as above.
Also
By macro do you mean ilogic trigger? I really mean a macro. or are you actually using a vb macro? Yes.
Would you be fine if it just made the files on the "before save" event trigger? (so you press save and it runs this ilogic rule to create all the associated files then saves the drawing) I would much prefer not to use an event trigger as such, for a simple reason: I am constantly saving and discarding obsolete parts for new ones, and if it saved a copy as a diferent file format everytime, our network would be a total chaos.
Regarding the code, I did some progress:
' Find the drawing for the specified part of assembly.
Private Function FindDrawingFile(PartOrAssemblyDoc As Document)
Dim fullFilename As String
fullFilename = PartOrAssemblyDoc.fullFilename
' Extract the path from the full filename.
Dim path As String
path = Left$(fullFilename, InStrRev(fullFilename, "\"))
' Extract the filename from the full filename.
Dim filename As String
filename = Right$(fullFilename, Len(fullFilename) - InStrRev(fullFilename, "\"))
' Replace the extension with "dwg"
filename = Left$(filename, InStrRev(filename, ".")) & "dwg"
' Find if the drawing exists.
Dim drawingFilename As String
drawingFilename = ThisApplication.DesignProjectManager.ResolveFile(path, filename)
' Check the result.
If drawingFilename = "" Then
' Try again with idw extension.
filename = Left$(filename, InStrRev(filename, ".")) & "idw"
' Find if the drawing exists.
drawingFilename = ThisApplication.DesignProjectManager.ResolveFile(path, filename)
' Return the result.
If drawingFilename <> "" Then
FindDrawingFile = drawingFilename
Else
FindDrawingFile = ""
End If
Else
' Return the result.
FindDrawingFile = drawingFilename
End If
' Open Drawing
Dim oDoc As Document
Set oDoc = ThisApplication.Documents.Open(drawingFilename, True)
' From here on out I don't know
drawingFilename = ThisApplication.ActiveDocument '?
End Function
I already have a Rule for my drawings that saves the drawing as .pdf and .dxf
The next step would be to set the drawing as the active document and make it run its Rule.
In the end, if all goes well, I can change the code to open the part from the drawing, and make it run a rule to save a copy of the part as .step, without having to do it manually.
João Silva
Mechanical Engineer