Author Topic: An AutoLISP/AutoCAD oddity... (also: multiple join layers LISP routine)  (Read 7259 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
All I use is :
Code: [Select]
               (setq all (ssget "_X"
                                (list '(0 . "ARC,LINE,LWPOLYLINE")
                                      (cons 410 (getvar 'CTAB))
                                      (car (setq lst (cons l lst)))
                                )
                         )
               )
What if you are working in a viewport?

Code: [Select]
needs
                                more
                                                                tabs
and cowbell!
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Quote
What if you are working in a viewport?
Still returns the Tab Name, but if you are in an active VP your method get all of model space not just what you see.
I always move to Model space, seldom do anything through the vp that affects all of model space.
I now see your intent though. Just not the way I work.  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Quote
What if you are working in a viewport?
Still returns the Tab Name, but if you are in an active VP your method get all of model space not just what you see.
I always move to Model space, seldom do anything through the vp that affects all of model space.
I now see your intent though. Just not the way I work.  8-)
I rarely ever work through the viewport (find it to be bad practice), but even I go against my own practices and when I do, I want it to select properly.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Pad

  • Bull Frog
  • Posts: 342
Re: An AutoLISP/AutoCAD oddity... (also: multiple join layers LISP routine)
« Reply #18 on: March 01, 2012, 08:58:30 AM »

and here's the rewrite I did today:
Code: [Select]
(defun c:MJL (/ pedit 4ten ss i l lst all)
  ;; Join all on selected object(s)' layer
  ;; Alan J. Thompson, 06.28.11

  (if (setq pedit (eq (getvar 'PEDITACCEPT) 1)
            4ten  (if (eq (getvar 'CVPORT) 1)
                    (cons 410 (getvar 'CTAB))
                    (cons 410 "Model")
                  )
            ss    (ssget "_:L")
      )
    (repeat (setq i (sslength ss))
      (if (and (setq l (assoc 8 (entget (ssname ss (setq i (1- i))))))
               (not (vl-position l lst))
               (setq all (ssget "_X"
                                (list '(0 . "ARC,LINE,LWPOLYLINE")
                                      4ten
                                      (car (setq lst (cons l lst)))
                                )
                         )
               )
          )
        (if pedit
          (vl-cmdf "_.pedit" "_m" all "" "_J" "" "")
          (vl-cmdf "_.pedit" "_m" all "" "_Y" "_J" "" "")
        )
      )
    )
  )
  (princ)
)


Hi Alan.  this is a very useful routine.  Wondered if it was possible to add a check on the linetype to the mix.  So that if two polylines which are on the same layer but one is continuous linetype and the other hidden then they aren't joined.  Cheers P

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: An AutoLISP/AutoCAD oddity... (also: multiple join layers LISP routine)
« Reply #19 on: March 01, 2012, 11:41:08 AM »
Alan, the error is obvious, you are tying to entget entities that were already pedited/joined and therefore deleted
think of two "connected" lines on the same layer as the initial selection set
« Last Edit: March 01, 2012, 12:09:40 PM by VovKa »