Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

API Question: Can you check custom properties w/o activating a part 1

Status
Not open for further replies.

MrMiller

Aerospace
Jan 30, 2004
54
0
0
US
Is it possible to get a custom properties value without actually opening the part?

Here is what I have and it opens the part. I want to determine whether I want to open the part based on the value of a custom property.


strCompDesc = swChildComp.GetPathName
Set swModel = swApp.ActivateDoc2(strCompDesc, True, 0)


 
Replies continue below

Recommended for you

It is possible to get a file's non-configuration-specific custom properties without loading the file into SW. Getting config-specific properties takes a bit of work. Stefan Berlitz told us how, once. It wasn't pretty.

[bat]"When everyone is thinking alike, no one is thinking very much." --Eckhard Schwarz (1930--2004)[bat]
 
MrMiller,
Yes, Open explorer and RMC on the model in question and click on properties, then Custom. We do not put our properties in the drawing so they are blank, but the models have the properties just fine.
That does not help you with API which I am sure it can be done in Visual Basic 6 but do not know how. Sorry.


Bradley
 
TheTick

I'm interested to know how Stefan Berlitz solve the config-specific properties problem (geting them without opening the file). Can you give me more details where to find this information?

Thanks
 
I spent an hour last night looking for that information (I think it was Stefan who sent it to me).

One thing that Iam becoming certain of: then answer does not lie with the SW API. We are examining a file's properties outside the SolidWorks context. This is probably done with Windows API (i.e. "Declare Sub name Lib "libname"). A good resource for Windows API knowledge is <
[bat]"When everyone is thinking alike, no one is thinking very much." --Eckhard Schwarz (1930--2004)[bat]
 
While this is possible, it was so much work I consider it more of a 'stunt' than a process.

Ive done it on a limited basis, and wouldnt consider the code robust enough to read ANY prop on ANY version, but Ive tweaked it enough to read the props we use at my company, and for the possible versions I might encounter at my company.

What it basically comes down to is writing your own standalone code to interpret the binary data in the IStream, and be aware of the switching back and forth between UniCode strings that not only vary between versions and languages, but also between *different nodes in the IStream* .....
 
MrMiller

After reading you original post, I think we are all on the wrong track. The issue isn't really how to get the properties without opening the part. It seems to be how to get a component's ModelDoc object without activating it.

If you have a component object, you can access its ModelDoc object (which you need to get custom properties) using Component2::GetModelDoc.


For instance, here is a function that returns a variant array of custom property names for a given component and configuration.
Code:
Function ComponentPropNames(inComponent As SldWorks.Component2, ConfigName As String) As Variant
'the below code assumes that inComponent has been assigned a SW component object
Dim ComponentsModelDoc As SldWorks.ModelDoc2
Dim PropNames As Variant
Set ComponentsModelDoc = inComponent.GetModelDoc
ComponentPropNames = ComponentsModelDoc.GetCustomInfoNames2
End Function

[bat]"When everyone is thinking alike, no one is thinking very much." --Eckhard Schwarz (1930--2004)[bat]
 
Thank You Tick!!! That is exactly what I was trying to do. I already tried what you explained and it worked out perfect.

I owe you big for this but being a novice API programmer I don't know that I'll ever be able to.

I emailed SolidWorks API help as well and they seemed be on the wrong track too. They mentioned something about a Document Manager tool to view these properties. Whatever???

At any rate I'm off and cruising with my macro again.

Thanks again,
Jeff

 
Status
Not open for further replies.
Back
Top