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: 

iLogic to print top level idw

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
karthur1
1048 Views, 7 Replies

iLogic to print top level idw

I am trying to get iLogic to print the referenced detail drawings AND the idw of an assembly that I have open.  I have it printing the details, but having a little trouble getting it to print the idw of my assembly.

 

The code is in two sections.... the "Component drawings" and the "Top Level Drawing".  After it prints the component drawings, it will print the last component drawing again, and then it opens the Top level drawing, but it does not print it.  I am trying to piece together a couple different codes I have been using and I am no code shark.

 

I would like it to print the details, then the top level idw and then close the top level idw.

 

Any help appreciated.

Kirk

 

 

Tags (3)
7 REPLIES 7
Message 2 of 8

Hi karthur1,

 

I only glanced at it, but I think it is this line:

 

'- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - -
'Dim oAsmDrawDoc As AsmDrawingDoc
oAsmDrawing = ThisDoc.ChangeExtension(".idw")
oAsmDrawingDoc = ThisApplication.Documents.Open(oAsmDrawing, True)
oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -3)

'write out the PDF for the Top Level Assembly Drawing file

oAsmDrawDoc = ThisApplication.Documents.Open(idwPathName, True)

 

I think you can do this but again, I only looked at it briefly and didn't test it.

 

'- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - -
'Dim oAsmDrawDoc As AsmDrawingDoc
oAsmDrawing = ThisDoc.ChangeExtension(".idw")
oAsmDrawingDoc = ThisApplication.Documents.Open(oAsmDrawing, True)
oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -3)

'write out the PDF for the Top Level Assembly Drawing file

            
            
            oAsmDrawDoc = ThisApplication.ActiveDocument
oAsmDrawDoc = ThisApplication.Documents.Open(oAsmDrawing , True)
oAsmDrawDoc.Activate oDrgPrintMgr = oAsmDrawDoc.PrintManager oDrgPrintMgr.AllColorsAsBlack = False oDrgPrintMgr.ScaleMode = kPrintBestFitScale oPrintMgr = ThisApplication.ActiveDocument.PrintManager

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 3 of 8

Curtis,

I have another question about this code if you dont mind.  When I run this, I want to do some error checking and make sure that it is being ran against an assembly file. If it is not an iam, then I want it to exit rather than giving some weird error.

 

 I copied some code that you had in another iLogic file, but it doesn't work.  If I run this against a file other than an iam, I get an error message like this.  I also tried this with your complete iLogic code and it gives the same error below.

 

2016-08-31_1009.png

 

Can you look at this and tell me what needs to change to make it work?  I think the problem is right in this area, but I am not sure what it needs to be changed to.

 

2016-08-31_0957.png

 

Thanks,

Kirk

 

Message 4 of 8

Hi karthur1,

My original example at the link  you provided contains the same issue . Smiley Embarassed

 

We just need to move the "check " up to the top, otherwise the attempt to define the document as an AssemblyDocument:

 

Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument

 

 

...creates an error.

 

 

 

So this should work:

 

'check that the active document is an assembly file
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If

'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 5 of 8

That did the trick.  My completed code is attached.  I like being able to print to PDF rather than doing a "Save As" to PDF.  I just don't like the Layers panel in the pdfs.  Anyways, attached is my final iLogic code that I have pieced together (and added to in places) from different codes that you and others have posted here.

 

 

Thanks again,

Kirk

 

Tags (3)
Message 6 of 8

 

Thanks karthur1,

 

I'm sure others will find your attachment helpful ( I marked it as a solution too).

 

I'm going to add these bullets to help it come up in future searches as well:

  • iLogic PDF Without Layers
  • iLogic PDF Turn Off Layers
  • iLogic PDF No Layers
  • iLogic Print to PDF
  • iLogic PDF All Components
  • iLogic PDF Entire Assembly

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 7 of 8
donald_haxhiu96w
in reply to: karthur1

la regola funziona perfettamente. ma è possibile però averla, che stampa in automatico il formato del foglio, e che rilevi in automatico sia il formato orizzontale che il formato verticale del foglio?

Message 8 of 8

Hi @donald_haxhiu96w.

Ho dovuto usare un traduttore per capire la tua risposta, quindi spero di aver capito bene.

In allegato è presente un file di testo contenente un codice di regola iLogic alternativo che è possibile provare. Ho separato il codice in 3 routine. La routine 'Principale', una routine per trovare il file di disegno e una routine per stampare un file di disegno.

Questo codice presuppone che i disegni utilizzino l'estensione di file ".idw" e che si trovino nella stessa cartella del file di modello e abbiano lo stesso nome file del file di modello. In caso contrario, potrebbe essere necessario modificare l'unica routine per trovare il disegno.

È inoltre possibile esaminare il codice all'interno della routine che stampa il file di disegno. Contiene molte righe di codice. Ogni linea è un'altra possibile opzione che può essere modificata in base alle nostre esigenze. Ho lasciato molte di queste righe commentate, in modo che vengano ignorate quando la regola viene eseguita, ma è possibile modificare quali righe sono commentate e su quali valori sono impostate, se necessario.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report