×
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

Document visibility in macro

Document visibility in macro

Document visibility in macro

(OP)
I have a macro that I made in SW2008 that do not seem to work in SW2009.  The problem seems to lie within the following line of code:

  visibility = swApp.DocumentVisible(False, swDocPart)

When I run the macro, I get an error that says "Compile error: Expected Function or variable" and it highlights the ".DocumentVisible" part of the code.

I know it used to work, and it does not appear that the method is obsolete, but I cannot figure this out.  I use the 2008 help file still, because the 2009 one does not make sense to me.

My goal is to open a part without loading it into memory to read a custom property on the "Configuration Specific" tab.  I want to run this macro against about 1000 parts, so loading them into memory just to read one property is very unnecessary.

Thanks,
Matt

RE: Document visibility in macro

Not sure about your specific issue, but your basic premise is flawed.  You cannot "open a part without loading it into memory" in SolidWorks.  Even if it doesn't have its own window, it loads it into memory.  

What you want to use is the swDocumentMgr.dll interface.  It can directly access many parts of the SW file (including configuration-specific custom properties) without opening the file in SW.  SW doesn't even have to be running.  The macro can run from Excel or even VBScript.  You just have to write an email to apisupport@solidworks.com and request a license key to use it.  The 2008 API help file even has documentation for it.

-handleman, CSWP (The new, easy test)

RE: Document visibility in macro

(OP)
handleman,
Thank you, as usual, for the prompt response.

I guess my wording was a little off.  Just to clear up the confusion...  I know SW still loads the part, but it is much less intensive on system resources, and therefore much quicker, if it is not loaded as visible.  This is from the help file, and is basically I meant to say I was trying to avoid:  "Opening a model causes SceneGraph to display the model.  SceneGraph uses maps with defaults sizes of 2MB - 3MB for even the simplest model."

I resolved the problem by changing a couple lines of code.
  "Dim swApp As SldWorks.SldWorks" changed to"Dim swApp As ISldWorks"
  "visibility = swApp.DocumentVisible(False, swDocPART)" changed to "swApp.DocumentVisible False, swDocPART"

Either way, I will definitely try your suggestion.  This seems like the ideal solution since it does not have to actually open the file.  I already got the info I needed out for now, but I am sure this will come up in the future.  This method should save me quite a bit of time.

Thanks again.

 

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