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: 

Open PDF from IDW

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
madstrolle
307 Views, 8 Replies

Open PDF from IDW

Hi,

I would like have the option to open PDF file from the IDW I have open?

Below you can see our structure.

03.Native: contains all the IDW files.

01.PDF: contains the PDF generated from the IDW in 03.Native.

 

madstrolle_0-1695707537787.png

 

8 REPLIES 8
Message 2 of 9
FINET_Laurent
in reply to: madstrolle

Hi @madstrolle

 

The folowing code opens the pdf, that has the same name as the openned drawing document the rule is fired from :

Dim actDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
Dim file As String = actDoc.FullFileName 'full drawing path
Dim name As String = actDoc.DisplayName 'drawing name

Dim dir As String = "03.Native"
Dim targetDir As String = "01.PDF"

Dim s As String = Left(file, file.Length - (dir.Length + name.Length) - 1) '-1 for \
Dim pdfname As String = Left(name, name.Length - 4) & ".pdf" 

Dim pdfdoc As String = s & targetDir & "\" & pdfname

ThisDoc.Launch(pdfdoc)

Does this works as intented ?

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 3 of 9
madstrolle
in reply to: FINET_Laurent

Hi @FINET_Laurent ,

 

Sorry, it's not working.

I says that it can't find the file.

Below is error message, if it helps.

Thanks😊

madstrolle_0-1695715267245.png

madstrolle_1-1695715318640.png

 

Message 4 of 9
FINET_Laurent
in reply to: madstrolle

Hi @madstrolle,

 

From what I can see, the document you are firing the rule from is a new document that has not been saved, thus missing the extension in the display name. Please save the document on your computer before firing the rule.


Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 5 of 9
madstrolle
in reply to: FINET_Laurent

Hi @FINET_Laurent ,

 

The file is saved

Message 6 of 9
FINET_Laurent
in reply to: madstrolle

@madstrolle,

 

This might then be due to windows directory options : No file type extension - Autodesk Community - Inventor

Anyway, to fix the issue (line 9), here is the code :

Dim actDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
Dim file As String = actDoc.FullFileName 'full drawing path
Dim name As String = actDoc.DisplayName 'drawing name

Dim dir As String = "03.Native"
Dim targetDir As String = "01.PDF"

Dim s As String = Left(file, file.Length - (dir.Length + (name.Length + 4)) -1) '-1 for \
Dim pdfname As String = name & ".pdf" 

Dim pdfdoc As String = s & targetDir & "\" & pdfname

ThisDoc.Launch(pdfdoc)

 I might have done it wrong since I don't have any environement to test, can you try ?

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 7 of 9
madstrolle
in reply to: FINET_Laurent

@FINET_Laurent ,

 

Still not working, but it looks like it has the correct extension.

But in the path it says 001.PDF, where it should say 01.PDF?

madstrolle_1-1695722358402.png

 

Message 8 of 9
FINET_Laurent
in reply to: madstrolle

@madstrolle,

 

Perhaps the directories names are missing a space ? :

Dim actDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
Dim file As String = actDoc.FullFileName 'full drawing path
Dim name As String = actDoc.DisplayName 'drawing name

Dim dir As String = "03. Native"
Dim targetDir As String = "01. PDF"

Dim s As String = Left(file, file.Length - (dir.Length + (name.Length + 4)) -1) '-1 for \
Dim pdfname As String = name & ".pdf" 

Dim pdfdoc As String = s & targetDir & "\" & pdfname

ThisDoc.Launch(pdfdoc)

 

Kind regards,
FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 9 of 9
madstrolle
in reply to: FINET_Laurent

@FINET_Laurent ,

 

Of cause, my bad🙃

Now it's working👍

 

Thanks a lot😊

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report