Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Selecting all Entities 1

Status
Not open for further replies.

Vinay2479

Mechanical
Aug 16, 2007
18
IN
Hi,

I was trying to select all entities in a SolidWorks drawing through SolidWorks API.
The drawing has been created from a dxf.
I searched for a method for window selection, I think its not avaialble.
Can someone has steps to do such selection.

Regards,
Vinay
 
Replies continue below

Recommended for you

Since you have imported dxf file you haven't any drawing view just a Sheet View one. So you can get its sketch and retrieve all the segments.

Please refer the following macro:

- - - - - - - - -
Dim swApp As SldWorks.SldWorks
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swSketch As SldWorks.Sketch
Dim vSegs As Variant
Dim swSkSeg As SldWorks.SketchSegment
Dim i As Integer

Sub main()

Set swApp = Application.SldWorks

Set swDraw = swApp.ActiveDoc

Set swView = swDraw.GetFirstView

Set swSketch = swView.GetSketch

vSegs = swSketch.GetSketchSegments

For i = 0 To UBound(vSegs)
Set swSkSeg = vSegs(i)
swSkSeg.Select4 True, Nothing
Next

End Sub
- - - - - - - - -

BTW. You can also perform a window selection using IMouse interface. You can simulate mouse clicks from one corner to another opposite one so it will looks like 'real' selection

Artem Taturevich
CSWP
 
FYI. In SolidWorks 2010 Beta new method has been added ModelDocExtension::SketchBoxSelect which selects all of the entities in a sketch within the specified coordinates of the selection box. I think this is what are you looking for.

Artem Taturevich
CSWP
 
Thanks Artem for reply.
Your VB code will help me.
 
I was able to select all entities with your Code.
Actually I wanted to move all entities to one layer.
I selected all entities but now I am facing difficulty to find a method to move all entities to one layer.
I try to make the desired layer active after selecting, but its not working.
 
Try SketchSegment::Layer property. Set the layer for each segment in the loop


Artem Taturevich
CSWP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top