×
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

SW API training course

SW API training course

SW API training course

(OP)
has anyone taken it?  My company won't spring for the whole course (ROI blah, blah, blah), but I may have an opportunity to get the materials used in the course for self study.  

So far I've taught myself the basics of VB/VBA (e.g. I've written a custom prop macro and designed a nice dialog to go with it, wrote a macro to fire up a drawing after inputing sheet size, scale, materials notes etc, and a macro to traverse an assembly and spit p/n's and qty's to an excel spreadsheet), but I'm always looking to learn more.  Are the books/materials from the API class a good source for more advanced self teaching or is it more of a powerpoint presentation with no real content?

Thanks.

RE: SW API training course

I'm in the same boat. I need to learn API, but company won't pay right now. Any info you have so I can learn on my own? TheTick has some good info, but the PowerPoint presen from www.cpuandsimplepdm.com didn't help me much.

RE: SW API training course

Mostly, I learned by jumping into the deep end.  Remember your programming basics: plan your processes (read: "flowcharts") and begin with the end in mind.  Don't be shy about writing helper functions to simplify SW API calls.

It takes time to get comfortable with the SW object structure.  Most confounding is the differentiation between the "ModelDoc" object and the "PartDoc", AssemblyDoc", and "DrawingDoc" sub-objects.  Similarly, it helps to get comfortable with calling parent and child objects, such as getting a body or feature object from a part, getting a component from a selected face, or getting a part from a selected component.

When you define variables, use early binding.  For instance, define your swApp as Sldworks.SldWorks instead of the generic Object.  Make sure you incluse the SW type library "sldworks.tlb" in your references.  To do this, from within your VB macro editor, go to "Tools --> References" and make sure you have "SldWorks 2003 Type Library"[/] checked.

Again, the most confounding thing about this is the ModelDoc/PartDoc/AssemblyDoc/DrawingDoc thing.  Model files is best left defined as a generic object.  I sometimes define "dummy" ModelDoc, PartDoc, AssemblyDoc and DrawingDoc objects to use to get the pop-up lists, and then replace that object with the file object.

All this machinery making modern music can still be open-hearted.

RE: SW API training course

The help files can be tricky, especially if you dont have  a lot of VB experience, or a little 'C' experience: the data types are written from a 'C' programmers point of view.

here's a 'translation' of the data types from SolidSpeakish to VBA:


BSTR

    This is a String(NOT a fixed length string!). Used to hold names, etc.

    Dim MyString as string
    Dim MyString$


double

    Double precision. Uses decimals. The most accurate available in VBA.

    Dim MyDouble as double
    Dim MyDouble#


single    

      Not even sure if solidworks uses this one; holds decial numbers like Double, but not as
    high a range. If you're using a 64-bit processor, there is no extra overhead in
    using the double type, so I think pretty much everyone uses double now.
    
    Dim MySingle as single
    Dim MySingle!



LONG

        Long Integer. Holds Values in VBA that can be greater than 32565. Normally used to
    pass values defined in SWConst.bas

    Dim MyLong as long
    Dim MyLong&

BOOL    

        Boolean    . Boolean values, like True or false. Used a lot as return values to see
    if a function completed successfully. You can actually use INTEGERS here, too,
    because they are stored as integers anyway, so TRUE is the same value (False is
    always ZERO)

    
    Dim MyBool as boolean
    Dim MyBool as integer



LPDISPATCH

    This means OBJECT. Either dim a generic OBJECT. or dim a specific type of sw object:

    Dim MyModel as Object
    Dim MyModel as ModelDoc2



VARIANT

        ' in VBA, it can be *any* of the above types. And it WILL be if you dont specifially
    DIM it as anything else. Normally used in SW to hold arrays. of other data types.

    Dim MyVnt as variant
    Dim MyVnt

RE: SW API training course

Another caution about variants in VB:

If you have a variant retval that was returned from one function, and you want to use it in another function that requires a specific data type like Long, take the time to type in the conversion CLng(retval).  Sometimes a variant just won't do in place of a specific data type.

All this machinery making modern music can still be open-hearted.

RE: SW API training course

Thanks much. Anyone know of any good books or web sites on this subject?

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