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: 

Poor Quality of PDF when using save as ilogic or vba

14 REPLIES 14
Reply
Message 1 of 15
insomnix
854 Views, 14 Replies

Poor Quality of PDF when using save as ilogic or vba

I am having problems with the save as in vba and ilogic, It is producing an ugly pdf. Below is my code, attached is a sample drawing that was produced.

 

I just upgraded from inventor 2013 to 2015. The vba code worked perfectly in 2013, but when I tried to run this again in 2015, I get the attached. 

 

What I am doing in vba? I have an ipart factory, I am iterating through the factory and sending it to a "template" idw that then saves to a pdf with the part number name. When I switched to 2015, the pdf looked faded when generated. I then tried to use Ilogic to do the same thing, same result. With all that said, if I go to the inventor menu and save as pdf manually, the pdf looks fine. It appears to only be a problem when I try to saveas from code.

 

vba code:

Call oDrawingDoc.SaveAs(printsfileLocation  & oMemberName & ".pdf", True)

 

ilogic:
pdf = ThisDoc.Path & "\" & iProperties.Value("Project", "Part Number") & ".pdf"
ThisDoc.Document.SaveAs(pdf,True)

14 REPLIES 14
Message 2 of 15
bretrick30
in reply to: insomnix

I have used the code mentioned in the link below.  It works really well for me.

 

http://inventortrenches.blogspot.com/2011/07/ilogic-to-save-pdf-files-to-new.html

Message 3 of 15
insomnix
in reply to: bretrick30

I already tried that, and it works well when I only do one at a time. The problem comes when I initiate the vba. What renders when using the vba code looks like what I attached in my previos post.

Message 4 of 15
insomnix
in reply to: insomnix

Anyone? This is a real problem as I am trying to get a lot of work done in a short amount of time.

Message 5 of 15
insomnix
in reply to: insomnix

It's a bit of a pain and it adds some time, but I found a work around. Below is my cycle. After I open the template, update the view and saveas the idw with the member name as the file name, I then open that new idw so I can do a save as to create the pdf.

 

'get the drawing template
Set oDrawingDoc = ThisApplication.Documents.Open(templatesfileLocation & oMemberTemplate & ".idw")
Set oSheet = oDrawingDoc.ActiveSheet

'get the drawing view
Dim oView As DrawingView
For Each oView In oSheet.DrawingViews
Select Case oView.Name
Case "FRONT", "BACK", "ISO"
Call oView.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReplaceReference(ipartsfileLocation & oMemberFile)

If ScaleH > ScaleV Then
oView.[Scale] = ScaleV
Else
oView.[Scale] = ScaleH
End If
Case Else

End Select
Next

Call oDrawingDoc.Update2(True)
'save copy as one new idw using the member name in the prints folder
Call oDrawingDoc.SaveAs(printsfileLocation & oMemberName & ".idw", True)

'get the drawing
Set nDrawingDoc = ThisApplication.Documents.Open(printsfileLocation & oMemberName & ".idw")
Call nDrawingDoc.SaveAs(printsfileLocation & prefix & oMemberName & ".pdf", True)
Call nDrawingDoc.Close

 If anyone has a better solution, I would be happy to hear it.

Thanks

Message 6 of 15
rossano_praderi
in reply to: insomnix

Hi,

I would like to suggest you to have a look on these solutions.

 

http://forums.autodesk.com/t5/inventor-customization/convert-inventor-drgs-to-pdf-files/m-p/5263487#...

http://forums.autodesk.com/t5/inventor-customization/help-with-pdf-and-folder-creation-with-ilogic/m...

 

These are examples that can be helpful to you.



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 7 of 15
insomnix
in reply to: insomnix

OK, the changes I made helped, a little. I'm still getting a handful of items that look faded. What I discovered is that they only look faded like that when the "Raster View Only" check box is set to true on the drawing view. While I never set this to true, somehow it gets set to true when cycleing through the code, but not on every idw. It's like it is picking drawings at random to set raster view on. I need a vba method to make sure raster view is set to false.

 

My code works exactly the way I want in Inventor 2013, and I don't remember this Raster View check box in that version. I think if I can set this through code my code will work perfectly fine in 2015 too.

Message 8 of 15
rossano_praderi
in reply to: insomnix

Hi Insomnix,

this is the code to set all the views as "precise".

 

Call ThisApplication.ActiveDocument.MakeAllViewsPrecise

The opposite command is the follow.

 

Call ThisApplication.ActiveDocument.MakeAllViewsRaster

 

If you like to have more informations about the members of DrawingDocument, you will find them within the API help of Inventor.

 

Inventor 2013 don't have this option.

 



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 9 of 15
rossano_praderi
in reply to: insomnix

Hi, have you found a solution?

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 10 of 15
insomnix
in reply to: rossano_praderi

Not really. I did try the MakeAllViewsPrecise code and it did not appear to make a difference. I still get some "faded" views. The title block and dimensions never look faded, only the views. I don't understand it.

Message 11 of 15
rossano_praderi
in reply to: insomnix

Hi Insomnix,

title block and dimensions don't need to be rendered because are not images.
The views have to be rendered each time you update a related document.

 

Can you post a file as example?

 

 

Bregs

Rossano Praderi

 



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 12 of 15
insomnix
in reply to: rossano_praderi

There is an example in the first post.

Message 13 of 15
rossano_praderi
in reply to: insomnix

I know there is an example, but is more useful if you post the original file (IDW).



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 14 of 15
rossano_praderi
in reply to: insomnix

Ops..sorry...


Inviato da Samsung Mobile


--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 15 of 15
dhaverstick
in reply to: insomnix

Here is what I do to get around that problem

 

InventorDwgDoc.MakeAllViewsPrecise()  'Forces all drawing views to be precise views

 

For Each SheetObject In InventorDwgDoc.Sheets 'Iterate through the drawing sheets
    For Each DrawingViewObj In SheetObject.DrawingViews 'Iterate through the drawing views on the sheet
        Do While DrawingViewObj.IsUpdateComplete = False 'If the drawing view is still updating - go to sleep for 2 seconds
            System.Threading.Thread.Sleep(2000) 'go to sleep for 2 seconds
        Loop
    Next

    'Now that all the drawing views on that sheet are updated continue with creating the pdf file

    'Code to create pdf file of sheet
Next

 

Darren

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

Post to forums  

Autodesk Design & Make Report