iLogic/API: Override default name for new part created from template

iLogic/API: Override default name for new part created from template

DRoam
Mentor Mentor
461 Views
2 Replies
Message 1 of 3

iLogic/API: Override default name for new part created from template

DRoam
Mentor
Mentor

When we create a new part using Application.Documents.Add(), the part takes on the default naming scheme for new parts, which is Part1, Part2, Part3, etc.

 

When my add-in creates a new part, I want to override the default starting name to something more specific to what my add-in is creating, e.g., "FlatBarPart1". I need this override to meeting the following requirements:

  1. Override is used for the title bar caption
  2. Override is used for the document tab caption
  3. Override is used for the browser tree top node
  4. Override is used as the default name when saving
  5. Override is NO LONGER USED once the file has been saved; instead, the filename specified by the user should be used in all places listed above. This should happen automatically without needing any extra event handling or logic (just as happens to the default "PartX" caption when the file is saved).

If I change the Document.DisplayName property, this meets requirements 1, 3, and 4 above, but not 2 and 5.

 

Is there some way to override the default starting name for a new, unsaved file, such that it's correctly displayed in all the places listed above, AND automatically gets replaced by the actual filename when the document gets saved?

0 Likes
462 Views
2 Replies
Replies (2)
Message 2 of 3

SometimesInventorMakesMeAngry
Advocate
Advocate

I'm not sure what you mean by document tab caption, but try setting DisplayName to

""

after saving and that should clear the override.

0 Likes
Message 3 of 3

SometimesInventorMakesMeAngry
Advocate
Advocate

If by "document tab caption" you mean the View's caption, according to the documentation, View.Caption is a read/write property that you can set to whatever string you want.

 

Unfortunately, I saw no change in the GUI when I tested it. However, if you print the View.Caption while the code is executing, you will in fact see the value that you set it to. But if you then print without changing the value of Caption, I noticed the value goes back to what it was originally. Maybe someone else knows what's going on there.

 

View.Caption can be accessed from Application.Views and from Document.Views.

0 Likes