×
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

Selecting all Entities

Selecting all Entities

Selecting all Entities

(OP)
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

RE: Selecting all Entities

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

RE: Selecting all Entities

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

RE: Selecting all Entities

(OP)
Thanks Artem for reply.
Your VB code will help me.

RE: Selecting all Entities

(OP)
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.

RE: Selecting all Entities

Try SketchSegment::Layer property. Set the layer for each segment in the loop
 

Artem Taturevich
CSWP

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