ad project to i properties

Tiesvh
Explorer
Explorer

ad project to i properties

Tiesvh
Explorer
Explorer

Hi, I'm having some trouble adding my current project to the i properties, I often get stp from customers. files supplied, the i properties block is completely empty. I always create a project and would like to see the project number I am working in in my i properties, is something automatically possible? I already looked at i logic, but I didn't see anything about the current project or the like.

thanks in advance!
Ties v. Heugten

0 Likes
Reply
Accepted solutions (1)
334 Views
8 Replies
Replies (8)

blandb
Mentor
Mentor

Just to clarify, are you wanting to have your project file name automatically be applied to the project iproperty upon importing a step file? 

Autodesk Certified Professional
0 Likes

Tiesvh
Explorer
Explorer
Hi,
Yes thats what i want.
0 Likes

jtylerbc
Mentor
Mentor
Accepted solution

Yes, that's possible.  I have a rule that does that.  This puts the project file's name (without the .ipj extension) into the "Project" iProperty of a drawing.  I don't think anything would need to change for it to work in an assembly or part file, but it has never been tested that way.

 

Dim IPJ as String
Dim IPJ_Name As String
Dim IPJ_Path As String
Dim FNamePos As Long
'set a reference to the FileLocations object. 
IPJ = ThisApplication.FileLocations.FileLocationsFile
'get the location of the last backslash seperator 
FNamePos = InStrRev(IPJ, "\", -1)     
'get the project file name with the file extension
IPJ_Name = Right(IPJ, Len(IPJ) - FNamePos) 
'get the project name (without extension)
IPJ_ShortName = Left(IPJ_Name, Len(IPJ_Name) - 4)
'get the path of the folder containing the project file
IPJ_Folder_Location = Left(IPJ, Len(IPJ) - Len(IPJ_Name))

'Converts the project file name to UPPER CASE
IPJ_Shortname = UCase(IPJ_Shortname)

iProperties.Value("Project", "Project") = IPJ_Shortname

iLogicVb.UpdateWhenDone = True

 

Tiesvh
Explorer
Explorer
Hi,
I get a message that it is not working:
Error in rule: project rule, in document: Q-2023110-4005.ipt

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

Any idea?
0 Likes

jtylerbc
Mentor
Mentor

As I mentioned in my previous message, I've never used it in a part file before.  But I just tried it, and it worked fine for me, with no changes to the code.  Not sure why it would behave differently for you.

0 Likes

blandb
Mentor
Mentor

worked for me on both ipt and iam.. I just pasted the code into an empty file of each and all was fine.

Autodesk Certified Professional
0 Likes

Tiesvh
Explorer
Explorer

hi,

 

my bad, i tested it again on other files and it worked perfect thanks!

i closed the parts where i tested it on first and when i reopend it it worked fine

0 Likes

jtylerbc
Mentor
Mentor

Forgot to mention this earlier, but you'll want to set an Event Trigger for that rule.

 

The way I typically use it is with just the "New Document" trigger.  That's because sometimes our project file names are rather long, or there may be multiple "sub-projects" where we want that field on the drawing worded slightly differently, but are working under the same project file.  For those reasons, we only want this rule to be triggered at initial file creation, and after that the user can edit the "Project" property manually without the rule overwriting the edits.  

 

If your project file names are a bit more consistent, you may want to use something like "Before Save" instead, so it will check the project file name every time.

0 Likes