ssget for view coordinates

ssget for view coordinates

msarqui
Collaborator Collaborator
1,467 Views
9 Replies
Message 1 of 10

ssget for view coordinates

msarqui
Collaborator
Collaborator

Hi everyone!

 

I am trying to get a selection set to the view coordinates but with no luck.

 

Form here I get Lee Mac's code to get the coords.

(defun LM:ViewportExtents ( / c h v )
(setq c (trans (getvar 'viewctr) 1 0)
h (/ (getvar 'viewsize) 2.0)
v (list (* h (apply '/ (getvar 'screensize))) h)
)
(list (mapcar '- c v) (mapcar '+ c v))
)

But when I put it on the ssget it does not work.

 

 

(setq sel (ssget "_CP" (LM:ViewportExtents)))

Any help please?

 

0 Likes
Accepted solutions (2)
1,468 Views
9 Replies
Replies (9)
Message 2 of 10

pbejse
Mentor
Mentor
Accepted solution

@msarqui wrote:

Hi everyone!

 

 

(setq sel (ssget "_CP" (LM:ViewportExtents)))

Any help please?

 


 

"CP" Requires 3 or more points. the function gives you 2.

 

 

(setq sel (ssget "C" (car (Setq pts (LM:ViewportExtents))) (cadr pts)))

HTH

0 Likes
Message 3 of 10

msarqui
Collaborator
Collaborator

Hi

 
 
It worked very well in the model and in the paper space, but not inside a block editor with a visibility parameter.
 
Any idea on how to solve for block editor?
 
Thanks
 
0 Likes
Message 4 of 10

msarqui
Collaborator
Collaborator

Well, after some tests I'm starting to suspect that ssget does not select any parameters.

 

My goal is to move only the visible objects. Because I am using this in a block editor, could I use the "select" or the "move" command with coordinates?

0 Likes
Message 5 of 10

pbejse
Mentor
Mentor

@msarqui wrote:

Well, after some tests I'm starting to suspect that ssget does not select any parameters.

 

My goal is to move only the visible objects. Because I am using this in a block editor, could I use the "select" or the "move" command with coordinates?


Not sure what you mean by visible objects only msarqui, can you please tell us more.

0 Likes
Message 6 of 10

msarqui
Collaborator
Collaborator
Since I will use the selection inside the block editor and the block has visibilitys, I want to select only objects in the current visibility.
0 Likes
Message 7 of 10

pbejse
Mentor
Mentor

@msarqui wrote:
Since I will use the selection inside the block editor and the block has visibilitys, I want to select only objects in the current visibility.

 

(command "-bedit" "Blockname" "_BVMODE" "0" "_bvstate" "_set" "visibilityname")

... [ select and do your thing ] ... (command "BCLOSE" "Save" "")

HTH

0 Likes
Message 8 of 10

msarqui
Collaborator
Collaborator

I am already inside the block editor when calling the code. So, I was thinking something like this:

 

(command "select" "CP" (car (LM:ViewportExtents)) (cdr (LM:ViewportExtents)))

Or this:

(command "move" "CP" (car (LM:ViewportExtents)) (cdr (LM:ViewportExtents)) "" "\\")

But It is not working because I thing I need four points here...

0 Likes
Message 9 of 10

pbejse
Mentor
Mentor
Accepted solution

@msarqui wrote:

I am already inside the block editor when calling the code. So, I was thinking something like this:

 

(command "select" "CP" (car (LM:ViewportExtents)) (cdr (LM:ViewportExtents)))

Or this:

(command "move" "CP" (car (LM:ViewportExtents)) (cdr (LM:ViewportExtents)) "" "\\")

But It is not working because I thing I need four points here...


use "C" instead of "CP" 

 

 

(command "select" "C" (car (setq pts (LM:ViewportExtents))) (cadr pts))

 

if you insist on using "CP "

 


(Setq pts (LM:ViewportExtents))
(setq sel (ssget "CP" (list (car pts) (list (caar pts)(Cadadr pts)) (cadr pts) (list (caadr pts) (cadar pts))) ) )

 

 

0 Likes
Message 10 of 10

msarqui
Collaborator
Collaborator

@pbejsewrote:

use "C" instead of "CP" 

 

 

(command "select" "C" (car (setq pts (LM:ViewportExtents))) (cadr pts))

Thanks Patrick, that works.

0 Likes