Help with ssget??

Help with ssget??

DC-MWA
Collaborator Collaborator
1,006 Views
3 Replies
Message 1 of 4

Help with ssget??

DC-MWA
Collaborator
Collaborator

Hi all,

Our office recently voted and ultimately decided we would put our keynote tags in paper space. I don't love it, but... it is what it is.

Problem is the young drafters keep moving the view ports and not grabbing the keynote tags. This is a major issue.

I have come up with a way to remedy this, it's simple but seems to work.

My problem is when using the ssget selection, if a viewport is not the last item selected to move, it doesn't function as it's intended. If the user selects a viewport only or selects other items and the viewport last, it works great.

I'm at a loss on how to remedy this.

As always, forgive my "Frankenlisp" methods.

I have attached the lisp.

As always, thank you in advance for you input and assistance.

-dc

0 Likes
Accepted solutions (1)
1,007 Views
3 Replies
Replies (3)
Message 2 of 4

_gile
Consultant
Consultant
Accepted solution

This is due to the way you get s_type which sets the variable to the last entity in the selection set.

If I do not misunderstand, you have to check is the selection set contains some viewport (clipped or not) and on another side if the layout contain some mleader.

 

Try something like this:

(defun c:M (/ s ml i e f)
  (Prompt "\nMOVE")
  (if (setq s (ssget))
    (progn
      ;; check if the selection set contains a viewport
      (setq i -1)
      (while (and (setq e (ssname s (setq i (1+ i)))) (not f))
        (if (= "VIEWPORT" (cdr (assoc 0 (entget e))))
          (setq f T)
        )
      )
      (if (and f (ssget "X" (list '(0 . "MULTILEADER") (cons 410 (getvar 'ctab)))))
        (progn
          (alert "Don't forget to move tags along with the viewport fool!")
          (command "_.move" s)
          (Prompt "\nNow select tags if needed:")
        )
        (command "_.move" s "")
      )
    )
  )
  (princ)
)


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4

Moshe-A
Mentor
Mentor

@DC-MWA  hi,

 

bring in consideration that a drawing may contain number of layouts and a layout may contain number of viewports.

in your code you select all mleader objects on all layouts. so to solved this you have to get the viewport coordinates and call (ssget "w" ll ur) on the selected viewport and on the current layout Smiley LOL

 

Moshe

 

0 Likes
Message 4 of 4

DC-MWA
Collaborator
Collaborator

This works as I'd hoped. I'm hoping this is a temporary solution. I'd like to ultimately, have the program use the viewport coordinates in paperspace and the cross poly selection to move the viewport and everything within the boundaries of the viewport. Then it would grab all the keytags on top of the viewport in one move.

I'm thinking with clipped viewports this may be challenging.

 

0 Likes