Renaming a new file

 

Hi all,

First of all, congratulations for this site. It's been really a great help in creating code for Solid Edge. You've managed to create a great community.

I'm trying to do the following in an AddIn:

When I create a new file (say, and ASM or a PAR), I'd like to assign it a given name. By default, SE assigns "Pieza1.par" or "Assembly.asm", and I'd like the files to have a code.

I'm using C#, and AfterNewDocumentOpen(object theDocument) gets called, but all the properties (Name, Fullname, etc...) are readonly, thus I cannot modify them.

Can anyone help me with this or point me to the right direction ?

 

Regards,

Esteve

 

Posted by: Esteve Boix
Post date: 8/24/2009 12:04:30 AM

8 REPLIES

RE: Renaming a new file

Hi Esteve,

 

To rename the parts and subassembly use Revision Manager.

 

First create the object for revision manager

create object for documents in revision manager.

open the document(Assembly)

 

use loop for the documents in that linked documents in the open assembly

use logic to rename the parts or assembly what ever you want.

 

All the best,

 

Regards,

 

Sandeep

 

Posted by: Sandeep Shewale
Post date: 8/24/2009 12:30:23 AM

RE: Renaming a new file

 

Hi Sandeep,

Thanks for the quick reply.

I'm not sure to 100% understand your answer. What I'm trying to do is to give a new name to a newly created document (from a template), not renaming files once saved.

The reasoning is that I want all the files to be correctly "code-ified", that is, all the documents (in this case in Insight) should have a correct code. If I can give a code to the file when it's created from a template, the user does not have to do this himself. Maybe the approach is not correct... I'm open to suggestions Smiley Happy

Regards,

Esteve

 

Posted by: Esteve Boix
Post date: 8/24/2009 12:35:33 AM

RE: Renaming a new file

Esteve,

 

What I understand is when you open a new file, the name should be say 'Esteve.par' instead of usual 'Part1.par' so that when users name that file, the code 'Esteve' is included in that file name.

 

One possible option was to change the corresponding registry key. But it seems, this is not saved in registry.

 

So, another possible option is to use the AfterNewDocumentOpen or some such event. As soon as you open the document rename it.

 

Its just a hint, I haven't tried it.

 

- regards,

 

Sanjay Kulkarni.

 

Posted by: Sanjay Kulkarni
Post date: 8/24/2009 2:34:34 AM

RE: Renaming a new file

 

Hi there Sanja,

Yeah that's exactly what I need.

I've been playing with the revision manager, but it seems to work only with documents opened through it's API, not with documents already opened in SE (which is my case).

I'll keep trying.

 

Thanks a lot for your help.

 

Regards,

Esteve

 

Posted by: Esteve Boix
Post date: 8/24/2009 3:34:11 AM

RE: Renaming a new file

Esteve,

 

I don't think Revision Manager would be of any use.

 

Revision Manager, as far as I understand, works with disk files ie files saved on the disk. Its open method has file path as one of the parameters.

 

- Regards,

 

Sanjay Kulkarni

 

Posted by: Sanjay Kulkarni
Post date: 8/24/2009 3:48:48 AM

RE: Renaming a new file

 

Hi again Sanjay,

Yeah the RevisionManager is not helpful in this case. I'm already using AfterNewDocumentOpen, but I don't know how to rename the document. The "Name" and "FullName" properties of the SolidEdgeDocument object are readonly, so I can't use them.

I think I'll have to think of another strategy to solve this.

Regards,

Esteve

 

Posted by: Esteve Boix
Post date: 8/24/2009 3:59:56 AM

RE: Renaming a new file

Esteve,

 

After some rethinking, do you really need to change the default name?

 

What you need is that a particular string is required to be included while saving the file first time.

 

May be, you could try one of these: AfterDocumentSave, BeforeDocumentSave of the ApplicationEvents or BeforeSave of the document object.

 

Again, just guesses without trial.

 

- Regards,

 

Sanjay Kulkarni

 

Posted by: Sanjay Kulkarni
Post date: 8/24/2009 4:19:05 AM

RE: Renaming a new file

 

Sanja,

I've been playing with this, and it might work. The problem, as usual, is that I cannot rename the file, so I've settled to intercept the save, and call a saveas on the object but modifing the name as I need.

It's a little weird, since then I will intercept my own SaveAs again, so I'll have to put some kind of control, but it should work.

Thanks a lot for your time and help.

I'll add this to my SDK wishlist Smiley Very Happy

Regards,

Esteve

 

Posted by: Esteve Boix
Post date: 8/24/2009 4:52:06 AM