TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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
(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
)
-
why not
command: .chspace
or
commnad: .EXPORTLAYOUT
-
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
-
Hi Diarmuid,
Give this a try:
(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)
)
-
Bingo!
thats the info i was looking for. "67" is the dxf code for mpace v paperspace. not 410.
Thanks again guys
Diarmuid
-
You're welcome Diarmuid :-)
-
Hi Lee,
What does the "~" mean?
("~VIEWPORT")
Regards
Diarmuid
-
Have a read of the wcmatch function and see if you can tell me :wink:
-
:-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
-
:-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:
(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
-
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: