Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Dimension One by one dynamically 1

Status
Not open for further replies.

nsaranya

Computer
May 20, 2010
7
Hi
can anyone help me how to select the dimension one by one dynamically through vba code. The code should work on click of a button I need to select the dimension one by one. I have did the code for single dimension selection and the selected dimension will add to list box. But how to select multiple dimension on single button click.
Regards
Saranya
 
Replies continue below

Recommended for you

The below code Im using for adding selected dimension to list. But before getting the selected dimension I want the select dimension manually one by one on click of a button

Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSelMgr = swDraw.SelectionManager
Set swDispDim = swSelMgr.GetSelectedObject6(1, 0)
Set swDim = swDispDim.GetDimension
If swSelMgr.GetSelectedObjectType3(1, -1) = swSelDIMENSIONS Then
listadditem.AddItem (swDim.Value & " - " & swDim.Name)
Else
MsgBox "Select Only Dimension"
End If
 
I can't understand what you are trying to do. Can you please write out the steps more clearly for how you want your program to work? Like:

1. User runs macro
2. Form appears
3. User selects a dimension (or multiple dimensions?)
4. User pushes a button and dimension information is added to the list
etc.



-handleman, CSWP (The new, easy test)
 
The following are the steps
1.User Run macro
2.Form opens
3."Select Dimension" button will be clicked
4. So my program should allow to select dimension
5. Once the dimension is selected then it should add to list

I dont know how to give provision for multiple dimension selection after click of a button
 
So... with your current macro, are you stuck with the form open? Like

1. User runs macro
2. Form appears
3. User cannot interact with the SolidWorks model while the form is on the screen?

-handleman, CSWP (The new, easy test)
 
I have created the form in vb6 and I will install as a dll. so the vb6 form will allow the interaction with solidworks.
 
OK, maybe I get it...

You want:
1. Run macro
2. Form opens
3. User hits "Select dimension" button
4. Macro watches for user to select a dimension
5. When the user selects a dimension it is added to the list

Is that right?

It is much easier and more reliable to program:

1. Run macro
2. Form opens
3. User selects a dimension (or multiple dimensions).
4. User hits "Add selected dimension(s)" button
5. Dimension(s) added to list.



-handleman, CSWP (The new, easy test)
 
Thank you for your suggestion. But I need the button to be clicked before selecting the dimensions(Selection of dimensions and adding to loop should happen on loop)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor