×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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)
        

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

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.

"When everyone is thinking alike, no one is thinking very much." --Eckhard Schwarz (1930--2004)
http://www.EsoxRepublic.com

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

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

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

What about PDMWorks API (if you have PDMWorks of course)?

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

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

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

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 <http://www.allapi.net>.

"When everyone is thinking alike, no one is thinking very much." --Eckhard Schwarz (1930--2004)
http://www.EsoxRepublic.com

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

See the last post in thread <Thread559-38430>.

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

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* .....

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

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

"When everyone is thinking alike, no one is thinking very much." --Eckhard Schwarz (1930--2004)
http://www.EsoxRepublic.com

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

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources