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)
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
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.
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
Hi,
I would like to suggest you to have a look on these solutions.
These are examples that can be helpful to you.
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.
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.
Hi, have you found a solution?
Bregs
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.
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
I know there is an example, but is more useful if you post the original file (IDW).
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