sketch selection and view orientation

Programming and macros
User avatar
mp3-250
Posts: 630
Joined: Tue Sep 28, 2021 4:09 am
Answers: 20
Location: Japan
x 702
x 347

sketch selection and view orientation

Unread post by mp3-250 »

I have a macro that at some point needs to select all the entities in the active sketch (3d sketch to be precise).
I was using a sub from codestack that looped all the entities and it worked. then i saw a macro made by a colleague used a simpler approach with the sketchbox select method.

https://help.solidworks.com/2016/englis ... elect.html

it went wrong in one case: in the isometric view nothing was selected.
my understanding (now) is that method mimic the flat (on screen) rectangle selection and it needs 2 point to draw it. FLAT on the screen.

Code: Select all

Visual Basic (Declaration)	 

Function SketchBoxSelect( _
   ByVal FirstPtX As System.Double, _
   ByVal FirstPtY As System.Double, _
   ByVal FirstPtZ As System.Double, _
   ByVal SecondPtX As System.Double, _
   ByVal SecondPtY As System.Double, _
   ByVal SecondPtZ As System.Double _
) As System.Boolean
so we got it wrong and put a Z coordinate too, like a 3d box driven volumetric selection.
so start and end points were like -200,-200,-200 200,200,200

to be "sure" to catch all the entities in the graphic area. looking at the result we probably drawn a selection box not flat to the screen ending up selecting nothing when in the isonetric view.

does it makes sense?
are those selection methods supposed to be flat to screen and their Z coordinates must be zero no matter what? like in the above example, but with z=0 -200,-200,0,200,200,0

should we be aware of some other "unexpected" behaviour?
User avatar
josh
Posts: 295
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 16
x 22
x 508

Re: sketch selection and view orientation

Unread post by josh »

Since you're actually wanting to select all entities, and the sketch is currently active, why not just use RunCommand with the swCommands_Edit_Select_All argument? Same result as hitting Ctrl-A on the keyboard.
User avatar
mp3-250
Posts: 630
Joined: Tue Sep 28, 2021 4:09 am
Answers: 20
Location: Japan
x 702
x 347

Re: sketch selection and view orientation

Unread post by mp3-250 »

Thank you. if it does not have any collateral effect I should give it a try.

Performance wise I would like to mInImize the calculation effort as on big models my main macro becomes heavier to run and as you said the action required os a CTRL+A equivalent. nothing more.

the sketchbox method is indeed view dependend, with both Z=0 from a side view it causes a macro error.
Post Reply