Get component name with VBA

Discussion in 'SolidWorks' started by hvdstroet, Aug 8, 2006.

  1. hvdstroet

    hvdstroet Guest

    I am trying to get a simple macro working in SW 2006. What I need is a
    message box which returns the selected component name. Which command do
    I use to get the name of an assembly component?
     
    hvdstroet, Aug 8, 2006
    #1
  2. hvdstroet

    Heikki Leivo Guest

    I am trying to get a simple macro working in SW 2006. What I need is a
    Have you tried the most obvious one, Name? :-?

    For example,

    dim modelDoc as SldWorks.ModelDoc2
    Set modelDoc = swApp.ActiveDoc

    Dim component as SldWorks.Component2
    Set component = modelDoc.SelectionManager.GetSelectedObject(1)

    MsgBox component.Name

    Or

    MsgBox component.Name2

    I recommend you to read the API help in SolidWorks Help menu.

    -h-
     
    Heikki Leivo, Aug 8, 2006
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.