TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: diarmuid on March 14, 2011, 07:48:22 AM

Title: using ssget to change from paperspace to model space
Post by: diarmuid on March 14, 2011, 07:48:22 AM
Hi Guy's I'm having a problem with the code below.  I wish to change all of the objects in paperspace into modelspace by changin the dxf code (410).  Can this be done or am i barking up the wrong tree?  But this code is giving me the error ; error: bad argument type: lentityp nil.  Can anyone shed some light?  Any pointers would be very much appreciated

Code: [Select]

(setq Currtab (getvar "ctab"))
(setq Modtab "model")
(setq allobjcts (ssget "x"))

(setq n (sslength allobjcts))  ;determines the amount of items select by the ssget "x" .
            (setq index 0)              ;resets the "index" value to zero
           
                (repeat n               ;Start of the loop
                        (setq elist (entget (ssname allobjcts index)))
                        (setq d1 (assoc 410 elist)) ; get the dxf code of the items in this instance it is a current layout tab value we are looking for "410"

                        (setq elistnew (subst (cons 410 Modtab )   d1 eList)) ;(subst newitem olditem lst) ; swap the new name for the old name in the list

                        (entmod elistnew)       ;apply the changes made to the list thus making the blocks swap for each other
                        (setq index (1+ index)) ;repeat until the list "n" is exhausted
                )

Title: Re: using ssget to change from paperspace to model space
Post by: pBe on March 14, 2011, 09:32:43 AM
why not
command: .chspace

or
commnad: .EXPORTLAYOUT

Title: Re: using ssget to change from paperspace to model space
Post by: diarmuid on March 14, 2011, 09:51:29 AM
thanks

i'm using AutoCAD 2008 so eportlayout wont do.  I've thought about your suggestion for chspace, its also a non runner it would mean that i would need to create a viewport and i dont want to create one as all of the effected filesare reference files anyway.

Thanskfor the input though

Diarmuid
Title: Re: using ssget to change from paperspace to model space
Post by: Lee Mac on March 14, 2011, 02:26:20 PM
Hi Diarmuid,

Give this a try:

Code: [Select]
(defun c:test ( / s i )
  (if (setq s (ssget "_X" '((0 . "~VIEWPORT") (67 . 1))))
    (repeat (setq i (sslength s))
      (entmod (list (cons -1 (ssname s (setq i (1- i)))) (cons 67 0)))
    )
  )
  (princ)
)
Title: Re: using ssget to change from paperspace to model space
Post by: diarmuid on March 15, 2011, 05:50:46 AM
Bingo!

thats the info i was looking for.  "67" is the dxf code for mpace v paperspace.  not 410.

Thanks again guys

Diarmuid

Title: Re: using ssget to change from paperspace to model space
Post by: Lee Mac on March 15, 2011, 08:48:33 AM
You're welcome Diarmuid  :-)
Title: Re: using ssget to change from paperspace to model space
Post by: diarmuid on March 15, 2011, 09:49:53 AM
Hi Lee,

What does the "~" mean?

("~VIEWPORT")

Regards

Diarmuid
Title: Re: using ssget to change from paperspace to model space
Post by: Lee Mac on March 15, 2011, 10:12:45 AM
Have a read of the wcmatch function and see if you can tell me  :wink:
Title: Re: using ssget to change from paperspace to model space
Post by: diarmuid on March 15, 2011, 10:18:42 AM
 :-o i didn't realise it was a wildcard charcter.  so it means anything will do except whats in the pattern. :?

So i've learnt something new.  probably means i'll forget one of my kids names now.  "Everytime i learn something new it pushes some old stuff out." (HJS). :-D

Thanks for all of the help.

Regards

Diarmuid

Title: Re: using ssget to change from paperspace to model space
Post by: Lee Mac on March 15, 2011, 10:35:32 AM
:-o i didn't realise it was a wildcard charcter.  so it means anything will do except whats in the pattern. :?

Correct :-)  We're selecting everything except Viewports.

You can use all wildcard patterns in ssget filter lists, e.g. to filter for anonymous blocks:

Code: [Select]
(ssget "_X" '((0 . "INSERT") (2 . "`*U*")))
There are loads of other things you can include with filter lists using the '-4' filter codes - everything is detailed in the VLIDE Help Files  ;-)

So i've learnt something new.  probably means i'll forget one of my kids names now.

 :lol:  :-D
Title: Re: using ssget to change from paperspace to model space
Post by: Dashmonkey on March 15, 2011, 06:27:35 PM
So i've learnt something new.  probably means i'll forget one of my kids names now.  "Everytime i learn something new it pushes some old stuff out." (HJS). :-D

Thanks to TheSwamp I no longer remember anything prior to my 9th birthday. :ugly: