Newell.SolidEdgeFileProperties

 

Hi Jason

 

I felt Your API for reading/writing file properties for Solid Edge documents. It's work fine.

It's possible to Append new (custom) file property trough this API? How?

 

Posted by: Dalibor Sidlo
Post date: 5/17/2006 9:13:11 PM

19 REPLIES

RE: Newell.SolidEdgeFileProperties

Dalibor,

 

I haven't looked at that API in a long time so I don't remember my reasons, but it appears that I left out the ability to add new custom properties. I'll see what I can do to get a new method that will do that.

 

Thanks.

 

Posted by: Jason Newell
Post date: 5/17/2006 10:07:45 PM

RE: Newell.SolidEdgeFileProperties

I do it using code like below in VB6:

 

Public seApp As Object

Public ChildPart As SolidEdgeDocument

Public x

 

'Create new part (assuem you already have handle to SE app)

Set ChildPart = seApp.Documents.Add("SolidEdge.PartDocument")

 

'Assign Name and Save

Call ChildPart.SaveAs("1234")

 

'Assign Custom attribute "P/N" for Part Number

Set x = ChildPart.Properties.Item("Custom").Add("P/N", "1234")

 

- Bill

 

Posted by: Bill Ledbetter
Post date: 5/18/2006 4:55:58 AM

RE: Newell.SolidEdgeFileProperties

Hallo Bill

I know it (and I temporarily use it), but I want to use Newell's library (out of SE).

 

Thank for Your interest.

 

Posted by: Dalibor Sidlo
Post date: 5/21/2006 8:03:31 PM

RE: Newell.SolidEdgeFileProperties

Hi,

 

Is anyone else having problems when writing a String to a custom property?

The value is returned fine from the API (I have written an extended FileProps API in VB.Net and it works fine there as well) but when I look in Explorer or in Edge the value is full of junk letters and the Type is 'Unknown'.

I have tried this on a few Machines and also on Word docs etc.

 

mmm...

 

 

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 8/1/2006 12:58:33 AM

RE: Newell.SolidEdgeFileProperties

Calum,

 

Put a break somewhere in the PROPVARIANT.FromObject() method and see what type of PROPVARIANT you get. I get a VT_LPWSTR which is a long pointer to a wide string which is what you should be getting.

 

I just did a quick test of my code and I see no problems. I'm able to write strings correctly.

 

Posted by: Jason Newell
Post date: 8/1/2006 1:25:23 AM

RE: Newell.SolidEdgeFileProperties

Hi Jason,

 

I get a VT_LPWSTR and the Marshal.StringToCoTaskMemUni method is being called. From the API I get the proper value back, just not in windows or edge...

I have attached your project and a test app - you just need a file C:/Part1.par with a custom prop "test"

 

Let me know what happens...

 

Cheers

Calum

 

Posted by: Calum McLellan
Post date: 8/1/2006 2:43:34 AM

RE: Newell.SolidEdgeFileProperties

Calum,

 

See the following changes. This doesn't make much sense to me because I figure we should be using Unicode for strings. It seems that Edge's Custom Tab only works in ANSI. Weird.

 

 

 

public static PROPVARIANT FromObject(object source)

{

PROPVARIANT propVariant = new PROPVARIANT();

Type type = source.GetType();

 

if (type.Equals(typeof(string)))

{

//propVariant.vt = VarEnum.VT_LPWSTR;

//propVariant.Ptr = Marshal.StringToCoTaskMemUni(source.ToString());

propVariant.vt = VarEnum.VT_LPSTR;

propVariant.Ptr = Marshal.StringToCoTaskMemAnsi(source.ToString());

}

 

 

Posted by: Jason Newell
Post date: 8/1/2006 2:57:44 AM

RE: Newell.SolidEdgeFileProperties

Funny - thought I'd tried that...

 

Thanks heaps, everythings fine now.

 

I have attached a VB.Net project that uses 'StructuredStorage.dll' - a VB.Net version of your dll. This already has Add methods for Properties and PropertyStorage (PropertySets in the SolidEdge world) It also has the option to use NTFS Properties instead of compound properties, meaning that you can add custom props to a pdf for example. The NTFS custom props are not viewable in Explorer, but you can read them with the API.

I haven't tested it fully yet, but after a few tests it seemed to be pretty stable - but it's still a BETA version

 

I also fixed a problem in all the other FileProperty APIs where it is not possible to open the properties read-only for a file that is already open in SE.

 

Anyway, anyone that wants to use it can do so freely, and any feedback is welcome.

 

Cheers

Calum

 

Updated download can be found here.

 

 

Posted by: Calum McLellan
Post date: 8/1/2006 3:17:49 AM

RE: Newell.SolidEdgeFileProperties

I was hoping your problem was a VB issue so that I could take a stab at you . Glad to see that you wrote your own version. Structured Storage is certainly a good skill to learn. I am interested in your additions and will be looking at those.

 

Posted by: Jason Newell
Post date: 8/1/2006 3:22:31 AM