That should an easy one for geniuses we have around here... I'm pretty new with Lisp. I first wrote a really simple and short lisp i called speedtrim. I did that because most of our users are used to press "enter" therefore selecting the whole drawing as cutting edges (trim command). With the size of files we work with :ugly:, and using AutoCad 2008, this is now causing crashes. Of course i think it's very lazy
wanting to avoid a simple crossing-window to select cutting edges.... but the task was so simple i wrote a lisp for them in no time. It simply selects every entities within the screen limits as cutting edge, so there is no selection to do for the user. I first called it Jeff Gordon Trim then set back to speedtrim.
Then i realized, blockreferences are not getting selected with SSGET "_C".....
So i got back into testing, and it seems it tried everything to get those blocksreferences in the selection set i use into TRIM command. Nothing will do it! My selection set always stays the same...obviously there is an issues with SSADD and "INSERT" entities... I'm sure lots of you know why... here what it looks like at the moment. I create a SS of blocks of the entire drawing, then filter to keep only those within screen limits. But i found no way to merge both SS. Already put too much time into this.
If anyone has an idea, I'll add you to my lisp-angels selection set... Thks in advance
(defun c:st (c:speedtrim))
(defun c:speedtrim(/ csd cig selset index bloclist blocset)
;screen limits
(setq csd (getvar "vsmax"))
(setq cig (getvar "vsmin"))
(setq selset (ssget "_C" (list (car csd)(cadr cig))(list (car cig)(cadr csd))))
(setq blocset (ssget "_X" '((0 . "INSERT"))))
(setq bloclist ())
(setq index 0)
;create a list of blocks vla-names
(repeat (sslength blocset)
(setq bloclist (append bloclist (list(vlax-ename->vla-object (ssname blocset index)))))
(setq index (1+ index))
);repeat
;evaluates which blocks are within screen limits
(mapcar '(lambda (blocvlaname)
(if (and
(< (car (vlax-safearray->list(vlax-variant-value(vla-get-insertionpoint blocvlaname))))(car csd))
(< (cadr (vlax-safearray->list(vlax-variant-value(vla-get-insertionpoint blocvlaname))))(cadr csd))
(> (car (vlax-safearray->list(vlax-variant-value(vla-get-insertionpoint blocvlaname))))(car cig))
(> (cadr (vlax-safearray->list(vlax-variant-value(vla-get-insertionpoint blocvlaname))))(cadr cig))
);and
(setq selset (ssadd (vlax-vla-object->ename blocvlaname) selset)) ; adds block to selset if within screen limits
);if
);lambda
bloclist
);mapcar
(vl-cmdf "_trim" selset "" pause )
)