File Path saving on the drawing

File Path saving on the drawing

Anonymous
Not applicable
2,194 Views
11 Replies
Message 1 of 12

File Path saving on the drawing

Anonymous
Not applicable

Hello all,

 

I have create iLogic to generate DWG and PDF files and now i would like to save path of this files on the drawing as on picture below.

 

 

Capture.PNG

 

 

Im using after save trigger to run iLogics

 

Trigger.PNG

 

iLogic.PNG

The problem is that i have to save this file twice to update path field.

For sure is other way to do this but im not good enough to fix that 🙂

I will be very grateful for help.

BR Marcin

 

0 Likes
2,195 Views
11 Replies
Replies (11)
Message 2 of 12

EelcoWiggers
Enthusiast
Enthusiast

Hello,

 

When you use the After Save Event Trigger it means that your rule is run after the document is saved so you have to save it again to save the changed path. This means that your file can always be saved because this will keep repeating itself. I think its best that you use the Before Save Event Trigger, this way you change the path and then the document is saved. I don't know what happens with a new document because when it's not saved before the path will be empty. Maybe in this case you have to save it twice.

 

Best regards,

Eelco

0 Likes
Message 3 of 12

Vladimir.Ananyev
Alumni
Alumni

Agree with Eelco, you should change your drawing document before Save.

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 4 of 12

Anonymous
Not applicable

Thanks Guys for yours reply.

 

I have change as you sugested and now im geting error message.

Error.PNG

 

This is rule im using

 

Imports SysIO = System.IO
Sub Main()


Workspacepath = ThisDoc.WorkspacePath ()

WorkspacePathLength = Len (Workspacepath)

Pathonly = ThisDoc.Path

Directorypath = strings.right(pathonly, pathonly.length-WorkspacePathLength)

DWGPath = "\\VPE-SERVER\Drawings" & Directorypath & "\" & ThisDoc.FileName (False) &".dwg"

iProperties.Value("Custom", "Path") =  DWGPath

End Sub

0 Likes
Message 5 of 12

MechMachineMan
Advisor
Advisor

Well... using your words/reading you can see the error stack (the window that pops up) has the words "String" in one of the top lines.

 

From this we gather your line with "Strings" on it is likely causing the error.

 

You can do a manual debug and put in lines like:

 

MsgBox(workspacepath.length)

 

to ensure that your variables have the values that you would expect, and work backwards from there to solve your problems.

 

Good luck.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 12

mslosar
Advisor
Advisor

Yeah, the dialog is saying the length has to be greater than zero (0) and I only see a single length statement.

 

Make sure your path is returning what you're expecting first. Msgbox is the great debugger 🙂

0 Likes
Message 7 of 12

mslosar
Advisor
Advisor

This:

 

SyntaxEditor Code Snippet

floc=ThisDoc.Path
fn=ThisDoc.FileName(True) 'with extension

MsgBox(floc & "\" & fn)

 

gives me a message box that pops up with the full path to my drawing file. 

 

Furthermore, you can edit your border template and place a piece of text where you want it and simply choose the Drawing Property of Filepath/Name. Gives the full location with extension. So unless that iProperty is needed elsewhere, it's built in already.

0 Likes
Message 8 of 12

Anonymous
Not applicable

Hi

 

This is message box on already saved file.

Capture.PNG

 

As you can see on the drawing i would like to have path for DWG files which are saved in other location.

0 Likes
Message 9 of 12

Vladimir.Ananyev
Alumni
Alumni

Suppose you have a drawing (with at least one drawing view) that is not saved yet, so it does not have name.  At this moment you may get the full filename of the model file that was used to create the base drawing view. This is shown in the following code fragment:

Dim st As String = ""

Dim s as String = ThisDoc.FileName(True) 'without extension
st += "Drawing filename = " & s & vbNewLine & "length = " & s.length & vbNewLine

Dim oDoc as Inventor.Document = ActiveSheet.View("VIEW1").ModelDocument
s = oDoc.Fullfilename
st += "Model filename = " & s & vbNewLine & "length = " & s.length & vbNewLine

Dim i As Integer = s.LastIndexOf("\")  
Dim folder As String = s.substring(0,i)

st += "folder name = " & folder  & vbNewLine & "length = " & folder.length

MsgBox(st)

2.png

 

Another path you can get is the active project workspace path ThisDoc.WorkspacePath(). 

Hope using these paths you could calculate any path for your DWG file and insert it into the drawing just before the save operation.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 10 of 12

Anonymous
Not applicable

Thanks for all sugestions 🙂

 

 

0 Likes
Message 11 of 12

Mark.Lancaster
Consultant
Consultant

For me...  I would've just done this on my drawing for the location and not worry about writing a program to get the file name and path.

 

12-11-2015 7-51-09 AM.jpg

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Message 12 of 12

mslosar
Advisor
Advisor

So, are you saying you have to save the files to both an IDW in one location, and a DWG in another location?

 

If that is the case, the same type of thing exists in Autocad as well. You can use Insert Field inside Autocad to put the full path/filename on a drawing sheet as well. Now, how to do that from inside Inventor, I don't know. 

 

At a guess it looks like you need to replace c:\vaultwork\Designs with \\Server\Drawings in your path.

 

If it's that simple, and it's always C:\Vaultwork\Designs you need to strip off, you can strip off the first 20ish characters of the path, leaving you with \10322\filename.idw. or whatever it was. Use the LEFT() and RIGHT() functions for this.

 

Replace idw with dwg. Or simply strip off the last 3 characters and add dwg to the end of the string.

 

Append \\Server\Drawings (if it's always the same) to the front and you have your DWG path.

 

In your case, i think i'd be tempted to put both paths on each sheet so you know where both are regardless of which one you're dealing with, because if you have to change one, for example, you have to change them both.

0 Likes