Call SolidWorks Macro from Visual Basic 6.0
Call SolidWorks Macro from Visual Basic 6.0
(OP)
Is it possible to call a SolidWorks Macro from a Visual Basic 6.0 program?
Bradley
SolidWorks Pro 2008 x64 SP3.0EV
PDMWorks Workgroup, Dell XPS Intel(R) Pentium(R) D CPU
3.00 GHz, 5 GB RAM, Virtual memory 12577 MB, nVidia 3400
e-mail is Lotus Notes






RE: Call SolidWorks Macro from Visual Basic 6.0
CODE
Running macros from this command can get flaky, especially if macro has forms, multiple modules, or programmer does a poor job of closing objects.
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: Call SolidWorks Macro from Visual Basic 6.0
I am working on it.
A star for you.
Bradley
SolidWorks Pro 2008 x64 SP3.0EV
PDMWorks Workgroup, Dell XPS Intel(R) Pentium(R) D CPU
3.00 GHz, 5 GB RAM, Virtual memory 12577 MB, nVidia 3400
e-mail is Lotus Notes
RE: Call SolidWorks Macro from Visual Basic 6.0
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
RE: Call SolidWorks Macro from Visual Basic 6.0
Yes, I got Eric’s macro (PropertySync.swp) to run the way I like it. I tried to convert the macro, following TheTick’s directions on his web page, I could not get it to run. It is not a simple macro, it has several modules.
Here is a link to the macro that Eric wrote a while back for this purpose. Really well done.
http://hom
Bradley
SolidWorks Pro 2008 x64 SP3.0EV
PDMWorks Workgroup, Dell XPS Intel(R) Pentium(R) D CPU
3.00 GHz, 5 GB RAM, Virtual memory 12577 MB, nVidia 3400
e-mail is Lotus Notes
RE: Call SolidWorks Macro from Visual Basic 6.0
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
RE: Call SolidWorks Macro from Visual Basic 6.0
RE: Call SolidWorks Macro from Visual Basic 6.0
This is the last line before exiting PropertySync.swp macro. What I have done is remove the operators touch from PropertySync.swp. The operator never sees the dialog box. The macro copies number and description from the part, (even if the part is not open) and copies number and description properties data into the drawing. Now the drawing always matches the part.
Bradley
SolidWorks Pro 2008 x64 SP3.0EV
PDMWorks Workgroup, Dell XPS Intel(R) Pentium(R) D CPU
3.00 GHz, 5 GB RAM, Virtual memory 12577 MB, nVidia 3400
e-mail is Lotus Notes
RE: Call SolidWorks Macro from Visual Basic 6.0
You should be able to export the DrawingModel class module out of the macro and into your application. Then you will need to get two instances of DrawingModel, one for the drawing and one for the model (part / assembly). Then you can get the properties from the model one and set them in the drawing one.
Assuming that drawing is a SldWorks.DrawingDoc for the current drawing the following code will get the property model for the drawing.
CODE
drawingPropertyModel.setTo drawing, "", drawingPropertyModel
Getting the property model for the part / assembly is similar, but more complex. The complexity comes from two sources: a drawing can have multiple views which reference different models, and the desired properties can be associated with either a model file or an individual configuration. Assuming that you want to use the file properties from the current view of the current sheet of the drawing you would use the following code to get the DrawingModel object for the model.
CODE
Set currentView = drawing.GetFirstView()
Set currentView = currentView.GetNextView
Set modelPropertyModel = New DrawingModel
modelPropertyModel.setTo currentView.ReferencedDocument, "", modelPropertyModel
If you want the configuration properties the last line would become:
CODE
Then it is a simple matter of:
CODE
Dim description As String
modelPropertyModel.getModelProperties(number, description, False)
drawingPropertyModel.setModelProperties(number, description, False)
I hope this is enough information so that you can work out the integration.
Eric
RE: Call SolidWorks Macro from Visual Basic 6.0
Your original code is working for me now. However this new information will help in my old code to make it easier for someone else to take over after I leave.
Thank you. A star for you.
Bradley
SolidWorks Pro 2008 x64 SP3.0EV
PDMWorks Workgroup, Dell XPS Intel(R) Pentium(R) D CPU
3.00 GHz, 5 GB RAM, Virtual memory 12577 MB, nVidia 3400
e-mail is Lotus Notes