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: 

Exporting pdf from Inventor Assembly when drawing name is not same as part

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
floccipier
821 Views, 9 Replies

Exporting pdf from Inventor Assembly when drawing name is not same as part

floccipier
Advocate
Advocate

Hi before asking this question I did some searching on forums if someone already asked similar question and I couldn't find anything. Is there a way to know from part/assembly if they got a drawing form them too (no of same/similar name) and then if it could be exported to as pdf. 

 

Thank you. 

0 Likes

Exporting pdf from Inventor Assembly when drawing name is not same as part

Hi before asking this question I did some searching on forums if someone already asked similar question and I couldn't find anything. Is there a way to know from part/assembly if they got a drawing form them too (no of same/similar name) and then if it could be exported to as pdf. 

 

Thank you. 

Labels (5)
9 REPLIES 9
Message 2 of 10
Ralf_Krieg
in reply to: floccipier

Ralf_Krieg
Advisor
Advisor

Hello

 

No. You can use Vault or some other CAD data managment software who keeps track of this. In an very, very simple way, you could write an iLogic that writes an iProp (e.g. "RefedDrawing") with fulldocumentname of the drawing in the referenced part/assembly document on save drawing.

But:

- Don't move any of the documents wihtout updating RefedDrawing-Property

- Don't place more than one model onto drawing, keep a 1:1 relationship

- Delete iProp in model when delete last view in drawing

- Delete iProp when delete drawing

- and many more manual ToDo

 


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com

Hello

 

No. You can use Vault or some other CAD data managment software who keeps track of this. In an very, very simple way, you could write an iLogic that writes an iProp (e.g. "RefedDrawing") with fulldocumentname of the drawing in the referenced part/assembly document on save drawing.

But:

- Don't move any of the documents wihtout updating RefedDrawing-Property

- Don't place more than one model onto drawing, keep a 1:1 relationship

- Delete iProp in model when delete last view in drawing

- Delete iProp when delete drawing

- and many more manual ToDo

 


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Message 3 of 10
floccipier
in reply to: floccipier

floccipier
Advocate
Advocate

Sorry I don't use vault, so in that case it is not possible to create pdf of idw's from assembly in case part numbers/subassembly names are name same as idw's?

0 Likes

Sorry I don't use vault, so in that case it is not possible to create pdf of idw's from assembly in case part numbers/subassembly names are name same as idw's?

Message 4 of 10
WCrihfield
in reply to: floccipier

WCrihfield
Mentor
Mentor

@floccipier , @Ralf_Krieg 

Hi guys. I picked up handy, simple little trick a while back that may help you in this situation.  It's not a perfect solution, but it's better than nothing, and a step in the right direction.  And it leads me to believe that maybe the model file may actually know if it has a drawing, due to how it works.  I don't know if you have noticed this subtle convenient tool, and I don't recall which version of Inventor it became available, but when you left click (which selects it) on the top node in your model document's model browser (usually shows the name of the model), then right click, then choose "Open Drawing" from the right-click menu, if you have created a dedicated drawing of this model before and saved it, it will open that drawing.  Using this knowledge and technique, I looked up which command is called/used in that situation.  It is "CMxOpenDrawingCmd".  It won't work by itself, but if you simulate clicking on that top browser node just before executing it, it works the same as the manual process.  So I created a simple little iLogic rule that does this.

Here is that rule:

 

ThisDoc.Document.BrowserPanes.Item("Model").TopNode.DoSelect
ThisApplication.CommandManager.ControlDefinitions.Item("CMxOpenDrawingCmd").Execute2(False)

 

Obviously, you can change the document reference how you want, but I'm pretty sure the model document has to be fully open and active (visibly) for this to work.  And you could most likely replace "Model" with the 'InternalName' "PmDefault", if there is a language barrier.

I don't use Vault either, and don't even have it installed, and I haven't recently/previously had the model's drawing open either, so it's not still in memory or anything, but this still works for me.  So, to me that means...the model document must somehow not only know IF it has a drawing, but also how to open it.  I don't know where this information may be stored, or how to retrieve it yet, but at least there's hope, right. 😉

 

PS:  After it opens the drawing document, that drawing becomes the 'active' document, so you can use ThisApplication.ActiveDocument to retrieve it and/or its FullFileName.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

@floccipier , @Ralf_Krieg 

Hi guys. I picked up handy, simple little trick a while back that may help you in this situation.  It's not a perfect solution, but it's better than nothing, and a step in the right direction.  And it leads me to believe that maybe the model file may actually know if it has a drawing, due to how it works.  I don't know if you have noticed this subtle convenient tool, and I don't recall which version of Inventor it became available, but when you left click (which selects it) on the top node in your model document's model browser (usually shows the name of the model), then right click, then choose "Open Drawing" from the right-click menu, if you have created a dedicated drawing of this model before and saved it, it will open that drawing.  Using this knowledge and technique, I looked up which command is called/used in that situation.  It is "CMxOpenDrawingCmd".  It won't work by itself, but if you simulate clicking on that top browser node just before executing it, it works the same as the manual process.  So I created a simple little iLogic rule that does this.

Here is that rule:

 

ThisDoc.Document.BrowserPanes.Item("Model").TopNode.DoSelect
ThisApplication.CommandManager.ControlDefinitions.Item("CMxOpenDrawingCmd").Execute2(False)

 

Obviously, you can change the document reference how you want, but I'm pretty sure the model document has to be fully open and active (visibly) for this to work.  And you could most likely replace "Model" with the 'InternalName' "PmDefault", if there is a language barrier.

I don't use Vault either, and don't even have it installed, and I haven't recently/previously had the model's drawing open either, so it's not still in memory or anything, but this still works for me.  So, to me that means...the model document must somehow not only know IF it has a drawing, but also how to open it.  I don't know where this information may be stored, or how to retrieve it yet, but at least there's hope, right. 😉

 

PS:  After it opens the drawing document, that drawing becomes the 'active' document, so you can use ThisApplication.ActiveDocument to retrieve it and/or its FullFileName.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 10

SometimesInventorMakesMeAngry
Advocate
Advocate

If the drawing is in the same folder, you can try to open every drawing (.idw or .dwg file) invisibly and check to see if DrawingDocument.ReferencedDocuments[1] is the same as the model (AssemblyDocument or PartDocument).

If it's not in the same folder, you could try checking folders recursively, but I'm pretty sure this would take a long time.

If the drawing is in the same folder, you can try to open every drawing (.idw or .dwg file) invisibly and check to see if DrawingDocument.ReferencedDocuments[1] is the same as the model (AssemblyDocument or PartDocument).

If it's not in the same folder, you could try checking folders recursively, but I'm pretty sure this would take a long time.

Message 6 of 10
Ralf_Krieg
in reply to: floccipier

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

@WCrihfield

This works only if the drawing has the same name as the model document and is saved in the same folder. As it looks like, Autodesk has done a simple replave ipt/iam with idw/dwg and open the file if exist. Or am I missed something?

 

@SometimesInventorMakesMeAngry 

Yes, if there's only one big folder for all documents, it will take a long time searching. It's the same as a Pack'n Go with search for drawings option. Works well with 10 files, but not with 10.000.

 

@floccipier 

As suggested in my last post, use an iLogic to write the drawing name to the model document. Create two external rules (WriteReferencingDoc and OpenReferencingDraweing) and paste in the code below. Open the iLogoc Eventrigger dialog. Add the WriteReferencingDoc rule to the Drawing - On save document event. After this, on every save of the drawing, the full path of the drawing will be written to the first referenced document.

If you run the OpenReferencingDrawing rule from the open model document, it wil check if drawing exists and open it. From there you can go on with an export to PDF routine.

 

 

WriteReferencingDoc

Dim oDrawDoc As DrawingDocument = ThisDrawing.Document 
Dim oRefedDoc As Document = ThisDoc.Document.ReferencedDocuments.Item(1)
Dim oPropSet As PropertySet = oRefedDoc.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Try
	oPropSet.Add(oDrawDoc.FullFileName,"ReferencingDrawing")
Catch
	If Not oPropSet.Item("ReferencingDrawing").Value=oDrawDoc.FullFileName Then 
		oPropSet.Item("ReferencingDrawing").Value = oDrawDoc.FullFileName
	End If
End Try

 

OpenReferencingDrawing

Dim oDoc As Document = ThisDoc.Document
Dim sPath As String
Dim oProp As Inventor.Property = Nothing

For Each oProp In oDoc.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
	If oProp.Name = "ReferencingDrawing" Then
		sPath = oProp.Value
		Exit For
	End If
Next

If oProp Is Nothing 
	MsgBox("iProperty 'ReferencingDrawing' not found. Exit.")
	Exit Sub
End If

If System.IO.File.Exists(sPath) Then
	ThisApplication.Documents.Open(sPath)
Else
	If MsgBox("Drawing '" & sPath & "' doesn't exist. Clear iProp?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
		oProp.Value = ""
	End If
End If

 

 


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com

Hello

 

@WCrihfield

This works only if the drawing has the same name as the model document and is saved in the same folder. As it looks like, Autodesk has done a simple replave ipt/iam with idw/dwg and open the file if exist. Or am I missed something?

 

@SometimesInventorMakesMeAngry 

Yes, if there's only one big folder for all documents, it will take a long time searching. It's the same as a Pack'n Go with search for drawings option. Works well with 10 files, but not with 10.000.

 

@floccipier 

As suggested in my last post, use an iLogic to write the drawing name to the model document. Create two external rules (WriteReferencingDoc and OpenReferencingDraweing) and paste in the code below. Open the iLogoc Eventrigger dialog. Add the WriteReferencingDoc rule to the Drawing - On save document event. After this, on every save of the drawing, the full path of the drawing will be written to the first referenced document.

If you run the OpenReferencingDrawing rule from the open model document, it wil check if drawing exists and open it. From there you can go on with an export to PDF routine.

 

 

WriteReferencingDoc

Dim oDrawDoc As DrawingDocument = ThisDrawing.Document 
Dim oRefedDoc As Document = ThisDoc.Document.ReferencedDocuments.Item(1)
Dim oPropSet As PropertySet = oRefedDoc.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Try
	oPropSet.Add(oDrawDoc.FullFileName,"ReferencingDrawing")
Catch
	If Not oPropSet.Item("ReferencingDrawing").Value=oDrawDoc.FullFileName Then 
		oPropSet.Item("ReferencingDrawing").Value = oDrawDoc.FullFileName
	End If
End Try

 

OpenReferencingDrawing

Dim oDoc As Document = ThisDoc.Document
Dim sPath As String
Dim oProp As Inventor.Property = Nothing

For Each oProp In oDoc.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
	If oProp.Name = "ReferencingDrawing" Then
		sPath = oProp.Value
		Exit For
	End If
Next

If oProp Is Nothing 
	MsgBox("iProperty 'ReferencingDrawing' not found. Exit.")
	Exit Sub
End If

If System.IO.File.Exists(sPath) Then
	ThisApplication.Documents.Open(sPath)
Else
	If MsgBox("Drawing '" & sPath & "' doesn't exist. Clear iProp?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
		oProp.Value = ""
	End If
End If

 

 


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Message 7 of 10
floccipier
in reply to: WCrihfield

floccipier
Advocate
Advocate
Works for same name idw's only until you manually browse the drawing and tell inventor that this is drawing for this item and then next time it would automatically open but doesn't work if you try opening it first time. but thanks for loads of other important information. I keep reading your answers to old posts and its always helpful. Thanks for that too.
0 Likes

Works for same name idw's only until you manually browse the drawing and tell inventor that this is drawing for this item and then next time it would automatically open but doesn't work if you try opening it first time. but thanks for loads of other important information. I keep reading your answers to old posts and its always helpful. Thanks for that too.
Message 8 of 10
floccipier
in reply to: Ralf_Krieg

floccipier
Advocate
Advocate
Thanks for this @Anonymous - I made it work using partially your suggestion, really appreciate the time you spent reading my question and leading me to solution.
0 Likes

Thanks for this @Anonymous - I made it work using partially your suggestion, really appreciate the time you spent reading my question and leading me to solution.
Message 9 of 10

Is it possible for you to post your solution (at least the part relevant to your question) so that others who may have the same problem in the future can reference it?
0 Likes

Is it possible for you to post your solution (at least the part relevant to your question) so that others who may have the same problem in the future can reference it?
Message 10 of 10

Whenever possible I can clean from my work related references and post here.
I pretty much followed what was suggested by @Anonymous. A rule that finds each drawing in specific workspace, opens it and injects a property to refenced document (ipt, iam). Other rule then (when run from assembly) connects parts and assemblies to their drawings with the help of this property. Not ideal solution that I was looking for, but works for me now as I am literally dealing with hundreds of rouge drawings.
0 Likes

Whenever possible I can clean from my work related references and post here.
I pretty much followed what was suggested by @Anonymous. A rule that finds each drawing in specific workspace, opens it and injects a property to refenced document (ipt, iam). Other rule then (when run from assembly) connects parts and assemblies to their drawings with the help of this property. Not ideal solution that I was looking for, but works for me now as I am literally dealing with hundreds of rouge drawings.

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

Post to forums  

Autodesk Design & Make Report