Author Topic: Problem: Adding a selection set of blocks to another ss with various entities  (Read 2427 times)

0 Members and 1 Guest are viewing this topic.

Sebb77

  • Guest
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".....   :cry:
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
Code: [Select]
(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 )

  )

Jeff_M

  • King Gator
  • Posts: 4098
  • C3D user & customizer
Step thru the program while it's running, you will find that the Inserts ARE in the SS, just the TRIM command is not using them

Sebb77

  • Guest
hum.. when i step thru i really see that the SS don't change at all... for sure they are in BLOCSET, but i can't get them to merge with SELSET..there is something i am missing here...
thks i'll check it tomorrow..

Andrea

  • Water Moccasin
  • Posts: 2372
there is one way...

I've also made some modif..

Code: [Select]
[color=blue] (command "_select" "_C" csd csd "")
  (setq items (ssget "_P"))
[/color]


Code: [Select]
(setq bloclist ())
  (setq index 0)
  ;create a list of blocks vla-names
  [color=blue](if blocset
    (progn[/color]
  (repeat (sslength blocset)

Code: [Select]
(defun c:st [color=blue]() [/color](c:speedtrim))
Keep smile...

Sebb77

  • Guest
Great, it works.....  thk you very much Andrea. The Select command was the key.
I owe you one more....




Andrea

  • Water Moccasin
  • Posts: 2372
but....i'm sure you can make more simple... :wink:
Keep smile...

Sebb77

  • Guest
 :-D

....and then it didn't work anymore in another drawing. THERE IS an issue with SSGET, blockref's and TRIM command.
But look what i came up with.. 5 lines. Just by putting the crossing window into the trim command. :lol:
(best regards Andrea)
Code: [Select]
(defun c:st ()(c:speedtrim))
(defun c:speedtrim(/ csd cig selset index bloclist blocset)
  ;screen limits
  (setq csd (getvar "vsmax"))
  (setq cig (getvar "vsmin"))
  (vl-cmdf "_trim" "_C" csd cig "" pause )
)



Andrea

  • Water Moccasin
  • Posts: 2372
:-D

....and then it didn't work anymore in another drawing. THERE IS an issue with SSGET, blockref's and TRIM command.
But look what i came up with.. 5 lines. Just by putting the crossing window into the trim command. :lol:
(best regards Andrea)
Code: [Select]
(defun c:st ()(c:speedtrim))
(defun c:speedtrim(/ csd cig selset index bloclist blocset)
  ;screen limits
  (setq csd (getvar "vsmax"))
  (setq cig (getvar "vsmin"))
  (vl-cmdf "_trim" "_C" csd cig "" pause )
)

Exactly what I had in mind.  ;-)
you'r quick !   :-D

Code: [Select]

  (vl-cmdf "_trim" "_C" (getvar "vsmax") (getvar "vsmin") "" pause )

« Last Edit: April 02, 2009, 03:12:53 PM by Andrea »
Keep smile...

T.Willey

  • Needs a day job
  • Posts: 5251
If you want trim ( or extend ) to select all visible edges, then just hit ' enter ' when it asks you to select, and it will select all visible edges by itself.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Sebb77

  • Guest
Quote
If you want trim ( or extend ) to select all visible edges, then just hit ' enter ' when it asks you to select, and it will select all visible edges by itself.

Doing so is crashing autocad 2008 with very large files, or at least it takes 1 minutes before the user can continue. I was assuming all edges in the drawing were selected, not only those visible (within screen limits).
Anyway, this simple line works great. It is a Race trim command. Not causing crashes anymore.
(vl-cmdf "_trim" "_C" (getvar "vsmax") (getvar "vsmin") "" pause )