Printing all drawings of an assembly file

Printing all drawings of an assembly file

Anonymous
Not applicable
5,165 Views
37 Replies
Message 1 of 38

Printing all drawings of an assembly file

Anonymous
Not applicable
Hello everybody,



I have written a program within Inventor that list all components of an assy with their properties (iproperties and properties from Producstream) and allow an export of the bill of material to Excel with our company layout.



I want to add a function to my program in order to print all drawings that belong to an assy.



I have the list of components and I want to use the new functionality of the Producstream menu that allows us to open the attached drawing.



But I don’t know which library and which property.



You have maybe another method??



Thank you in advance



Michel
0 Likes
5,166 Views
37 Replies
Replies (37)
Message 2 of 38

Anonymous
Not applicable

I don't understand your statement:

I have the list of components and I want to use the new functionality of the Producstream menu that allows us to open the attached drawing.

What new functionality? Are you talking about Productstream 2009 or Vault Manufacturing 2010? What do you mean by "attached drawing"? If the model is Inventor then the drawing is not technically an attachment in Productstream/Vault Manufacturing terminology. Attachments are non-referencing documents (like AutoCAD, Excel, Word, etc).

I'm guessing you want your custom application (the one you've attached an image of) to be able to download the associated drawing (idw) and print it. Yes?

0 Likes
Message 3 of 38

Anonymous
Not applicable
Hello,

You’re right; I’ve used the wrong word. You know maybe that French people are much better in French cuisine than in English.

I will use an example:

I have an .iam (let’s call it Mickey Mouse) composed of two .ipt (left ear and right ear) and one iam. (the body)

I also have a drawing for each .ipt and each .iam . (Mickey Mouse.idw/left ear.idw/right ear.idw/body.idw)

I want to use my program in order to print all the drawings that belong to Mickey Mouse.iam that is to say 4 drawings: Mickey Mouse.idw/left ear.idw/right ear.idw/body.idw

I want to print each drawing on an automatic way.

With the help of Autodesk, my program is still listing my 4 parts and assembly with theirs iproperties and properties from Productstream such as file path, personal part name…

Productstream 2010 allows the opening of the .idw that is associated to one .ipt or .iam.

If left ear.ipt is open and active, the button “Zeichnung öffnen” you can see in appendice will open left ear.idw.

If I can use a loop to open each .iam and .ipt from my structured list of material, I will be able to use the same function as on top to open/print the associated drawings.

Michel
0 Likes
Message 4 of 38

Anonymous
Not applicable
Hello everybody,

I've tried with the function FindWhereUsed but it is very limited.

Does anyone have another solution?

Cordially...

Michel
0 Likes
Message 5 of 38

Ralf_Krieg
Advisor
Advisor
Hello

Is your Application an AddIn or a Standalone? If it's a Standalone exe read on, otherwise - cut off the Apprentice part.
If you got the complete Filepath in your Listing, you can use it. In my opinion the ProductStream function only searches for an idw with the same name as your actual active part or assembly. The search starts in the same directory, including subdirectories and goes on in the directories defined in your project. If my suggestion is right, you don't need this function. If Productstream stores the files in a directory and not in a database, try the following:
Cut off the filetype in your String and add "idw", start an ApprenticeServer, open the document with your new created Filepath and print it. For more comfort, you could add a Form to control printing options. Edited by: krieg on Feb 2, 2010 2:30 PM

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 6 of 38

Anonymous
Not applicable
Hello Krieg,


The fact is that Productstream stores the files with an incremented number in a specified directory (stored by year/month...and so on).

Example: ENG-047034 for the .ipt (or .iam) and if I want to create the assossiated idw, Productstream will give the number ENG-047035 or any ENG-Number that does NOT exist. It's a database.

The file path always look like this: \\Cad-server\Compass_Data\Daten\2010\02\0\ENG-047034.ipt but the file path of the assossiated idw will look like \\Cad-server\Compass_Data\Daten\2010\02\0\ENG-047035.idw.

And I don't know how the link is created.

Michel
0 Likes
Message 7 of 38

Ralf_Krieg
Advisor
Advisor
Hello

Sorry, I missunderstood your question.
I can't tell you anything about Productstream and Queries to it's database.

The relation of an part or assembly to a drawing is, afaik, not stored in part/assembly. So you need to query the productstream database. The second way is to search through every drawing, if the referenced document is your part/assembly. Design assistent does it so. This could take a long time.

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 8 of 38

Anonymous
Not applicable
Hello krieg,

this is what I'm trying to do but I don't find the right Library.

How can I find the right one?

Michel
0 Likes
Message 9 of 38

Anonymous
Not applicable
I have done something like this. To find the corresponding drawing I used my own method. Unfortunately the reference are reverse: a drawing references its part and not the other way around. So an idea would be to open all drawings invisible in the current directory and pick the one that references your part.
0 Likes
Message 10 of 38

Anonymous
Not applicable
Hello afirmation,

the fact is that Inventor propose a Producstream menu that allows to open the idw of an ipt directly (see picture in appendice). As it goes pretty fast, I don't think they open all drawings of the current directory.

The idw can also be in an other directory than the ipt (If I start my .ipt in June and my .idw in July).

I've tried to go through the ribbon but i can't find the right menu in VBA.

I aggree with Krieg, I have to control Productsstream through Inventor (that is to say : to find the right library) in order to list all the documents where my ipt/iam is used in.

Michel
0 Likes
Message 11 of 38

Anonymous
Not applicable
Well I think inventor still has a problem because if the drawing does not have the exact name as the part, it fails in finding the drawing.

The command that Inventor uses to open the corresponding drawing document is "CMxOpenDrawingCmd". To use it to open the drawing for a given part use it like this:

inventorApp.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent, fileName);
inventorApp.CommandManager.ControlDefinitions["CMxOpenDrawingCmd"].Execute()
0 Likes
Message 12 of 38

Rene-J
Collaborator
Collaborator
First I know nothing about Productstream.

You can call the button command. like this

Dim oControlDef As ControlDefinition
Set oControlDef =
ThisApplication.CommandManager.ControlDefinitions.Item("ScxEditTextCmd")
oControlDef.Execute

To get Command name of the button
Private Sub UserInpEvts_OnActivateCommand(ByVal CommandName As String, ByVal Context As Inventor.NameValueMap) Handles UserInpEvts.OnActivateCommand
msgbox CommandName
End sub

Use the Event Handlers OnOpenDocument
to check when the drawing is open.

René J
0 Likes
Message 13 of 38

Anonymous
Not applicable

Does your program copy locally, all required files from Productstream based on a parent document or part number? Or does it expect the files to be already local, meaning your program analyzes the structure of the active document ans attampts to locate and print the associated drawings? If you need Productstream to copy the files locally then you'll need to learn some of Productstream's API. Doug Redmon has a site that can offer some insite: http://justonesandzeros.typepad.com/blog/. Do you use ECOs and Items in Productstream? If so, are you concerned with printing the latest version or a specific released revsion?

Do you know what Apprentice is? It is an interfaceless version (mostly read-only - except file properties, file references and a few things). I personally would use Apprentice's API (instead of Inventor's API) to do the printing. It's faster (no GUI) and you can print drawings without the model references if error trapped correctly. In Inventor's API help, review ApprenticeServer, ApprenticeServerDocument (assembly structure), ApprenticeServerDrawingDocument and ApprenticeDrawingPrintManager.

0 Likes
Message 14 of 38

Ralf_Krieg
Advisor
Advisor
Hello

I've found a paper of Autodesk university 2007 under http://augiru.augi.com/content/library/au07/data/paper/DE305-4.pdf about customizing Vault/Productstream. Maybe it helps you getting started. The second step is to take a look at the SDK in “C:\Program Files\Autodesk\DataManagement Server 20xx. There's the complete Documentation and Samples. Edited by: krieg on Feb 3, 2010 6:42 PM

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 15 of 38

Anonymous
Not applicable
Hello,

I’ve tried what you (afirmation) proposed me (VBA):

FileName = ThisApplication.ActiveDocument.FullFileName
Call ThisApplication.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent, FileName)
ThisApplication.CommandManager.ControlDefinitions.Item("CMxOpenDrawingCmd").Execute

I’ve no compilation problem but it does not execute anything.
On a normal way, using mouse and fingers, the associated .idw gets open.
I’ve tried different things till now without success.

I just reedit the thread to thank you all for your helpful message. I feel I'm very close to what I'm looking for.

Michel Edited by: Michel.Brun on Feb 4, 2010 12:31 PM
0 Likes
Message 16 of 38

Anonymous
Not applicable
I did not try it myself but I was hoping it would work. I'll send you a feedback after I look into it.
0 Likes
Message 17 of 38

Anonymous
Not applicable
Yes it was too easy to be true. The reason is that the command does not work for a given file name, but for the current browser selection. So the PostPrivateEvent used to sent the file name to the command is now useless.

The first thing that comes into my mind and which I tested that works is to select the wanted file in browser and then call "CMxOpenDrawingCmd". To select a node in browser you can do it as below. If it is an assembly you can select a document occurrence like this:

Inventor.ComponentOccurrencesEnumerator enumOcc = assemblyDoc.ComponentDefinition.Occurrences.get_AllReferencedOccurrences(doc);
assemblyDoc.SelectSet.Clear();
assemblyDoc.SelectSet.Select(enumOcc[1]);

if it is exactly the root assembly like this:
assemblyDoc.SelectSet.Clear();
assemblyDoc.SelectSet.Select(assemblyDoc.ComponentDefinition);

After that just call the command with: CommandManager.ControlDefinitions["CMxOpenDrawingCmd"].Execute()

These should work but I do not know if it is the best way.
0 Likes
Message 18 of 38

Anonymous
Not applicable
Hello, what a nice day today,

I have found the right command (see below)

' Get the CommandManager object.
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager

' Get control definition for the line command.
Dim oControlDef As ControlDefinition
Set oControlDef = oCommandMgr.ControlDefinitions.Item("AIMDOpenDrawingInContextMenuInternal")
'Set oControlDef = oCommandMgr.ControlDefinitions.Item("AIMDOpenDrawingInternal")

' Execute the command.
Call oControlDef.Execute


I will now do a loop to open all occurences and I will print all the drawings that are associated to my occurences. I will put it later on that thread.


But how can I get the vbExclamation message that I get when there are no associated Drawing to my occurence. See attached file.

I've tried with Displayalert so as Excel and an On Error routine but the line is already Call oControlDef.Execute
read.

I know that it's not the better way and I agree with cadfish1. I will try it with apprentice as soon as it will works with the first solution. But I first have to check how to command Productstream through Inventor.




Michel Edited by: Michel.Brun on Feb 5, 2010 11:11 AM
0 Likes
Message 19 of 38

Anonymous
Not applicable
Hello,

here's my code.... I hope it will help somebody else...
Cordialy
Michel

Keywords: Batch plot, All drawings plot, Printing all drawings, Print all drawings, associated drawings


If MsgBox("Are you sure?", vbYesNo) = vbYes Then

'Opening all associated parts

'Get the active assembly.
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument

'Get all of the referenced documents.
Dim oRefDocs As DocumentsEnumerator
Set oRefDocs = oAsmDoc.AllReferencedDocuments

'Iterate through the list of documents.
Dim oRefDoc As Document

For Each oRefDoc In oRefDocs

'Debug.Print oRefDoc.FullFileName

'Open iam or ipt
Dim oDoc As Document
Set oDoc = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)

'Get the CommandManager object
Dim oCommandMgr As CommandManager
Set oCommandMgr = ThisApplication.CommandManager

'Get control definition for the line command
Dim oControlDef As ControlDefinition
Set oControlDef = oCommandMgr.ControlDefinitions.Item("AIMDOpenDrawingInContextMenuInternal")

'Execute the command
Call oControlDef.Execute

'Print idw
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then

Dim oDraw As Document
Set oDraw = ThisApplication.ActiveDocument

'MsgBox oDraw.FullFileName

Dim oDrgPrintMgr As DrawingPrintManager
Set oDrgPrintMgr = oDraw.PrintManager
'Set the printer name
'oDrgPrintMgr.Printer = "XXXXXXX"

oDrgPrintMgr.PrintRange = kPrintAllSheets

'Set the paper size and scale
On Error Resume Next

Select Case oDraw.ActiveSheet.Size
Case kA4DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA4
oDrgPrintMgr.ScaleMode = kPrintCustomScale
oDrgPrintMgr.[Scale] = 1
Case kA3DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA4
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Case kA2DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA3
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Case kA1DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA3
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Case kA0DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA3
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Case Else

'Debug.Print "ungültiges Papierformat"

End Select

'Set the paper orientation
On Error Resume Next

Select Case oDraw.ActiveSheet.Orientation
Case kLandscapePageOrientation
oDrgPrintMgr.Orientation = kLandscapeOrientation
Case kPortraitPageOrientation
oDrgPrintMgr.Orientation = kPortraitOrientation
Case Else

'Debug.Print "ungültige Orientierung"

End Select

oDrgPrintMgr.SubmitPrint

'Close idw
oDraw.Close (True)

End If

'Close iam or ipt
oDoc.Close (True)

Next

'Opening Asmdrawing in context menu

Call oControlDef.Execute

Set oDraw = ThisApplication.ActiveDocument

'MsgBox oDraw.FullFileName

'Dim oDrgPrintMgr As DrawingPrintManager
Set oDrgPrintMgr = oDraw.PrintManager
'Set the printer name
'oDrgPrintMgr.Printer = "XXXXXXX"

oDrgPrintMgr.PrintRange = kPrintAllSheets

'Set the paper size and scale
On Error Resume Next

Select Case oDraw.ActiveSheet.Size
Case kA4DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA4
oDrgPrintMgr.ScaleMode = kPrintCustomScale
oDrgPrintMgr.[Scale] = 1
Case kA3DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA4
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Case kA2DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA3
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Case kA1DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA3
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Case kA0DrawingSheetSize
oDrgPrintMgr.PaperSize = kPaperSizeA3
oDrgPrintMgr.ScaleMode = kPrintBestFitScale
Case Else

'Debug.Print "ungültiges Papierformat"

End Select

'Set the paper orientation
On Error Resume Next

Select Case oDraw.ActiveSheet.Orientation
Case kLandscapePageOrientation
oDrgPrintMgr.Orientation = kLandscapeOrientation
Case kPortraitPageOrientation
oDrgPrintMgr.Orientation = kPortraitOrientation
Case Else

'Debug.Print "ungültige Orientierung"

End Select

oDrgPrintMgr.SubmitPrint

'Close idw
oDraw.Close (True)

Else

'No

End If
0 Likes
Message 20 of 38

karthur1
Mentor
Mentor

Found this code and I was trying to get it to work.  Get an error when I run it.  I copied/pasted it into the Inventor VB editor and then edited it a little.... added this:

 

2011-07-01_0803.png

 

Now, In Inventor, I open an assembly that has three parts to it.  All the parts have idws associated to them and they are stored locally.  When I run the code I get this error.

 

2011-07-01_0801_001.png

 

Can someone point me in the right direction as to what I'm doing wrong.

0 Likes