Author Topic: using ssget to change from paperspace to model space  (Read 3357 times)

0 Members and 1 Guest are viewing this topic.

diarmuid

  • Bull Frog
  • Posts: 417
using ssget to change from paperspace to model space
« 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
                )

If you want to win something run the 100m, if you want to experience something run a marathon

pBe

  • Bull Frog
  • Posts: 402
Re: using ssget to change from paperspace to model space
« Reply #1 on: March 14, 2011, 09:32:43 AM »
why not
command: .chspace

or
commnad: .EXPORTLAYOUT


diarmuid

  • Bull Frog
  • Posts: 417
Re: using ssget to change from paperspace to model space
« Reply #2 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
If you want to win something run the 100m, if you want to experience something run a marathon

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: using ssget to change from paperspace to model space
« Reply #3 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)
)
« Last Edit: March 14, 2011, 02:29:35 PM by Lee Mac »

diarmuid

  • Bull Frog
  • Posts: 417
Re: using ssget to change from paperspace to model space
« Reply #4 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

If you want to win something run the 100m, if you want to experience something run a marathon

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: using ssget to change from paperspace to model space
« Reply #5 on: March 15, 2011, 08:48:33 AM »
You're welcome Diarmuid  :-)

diarmuid

  • Bull Frog
  • Posts: 417
Re: using ssget to change from paperspace to model space
« Reply #6 on: March 15, 2011, 09:49:53 AM »
Hi Lee,

What does the "~" mean?

("~VIEWPORT")

Regards

Diarmuid
If you want to win something run the 100m, if you want to experience something run a marathon

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: using ssget to change from paperspace to model space
« Reply #7 on: March 15, 2011, 10:12:45 AM »
Have a read of the wcmatch function and see if you can tell me  :wink:

diarmuid

  • Bull Frog
  • Posts: 417
Re: using ssget to change from paperspace to model space
« Reply #8 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

If you want to win something run the 100m, if you want to experience something run a marathon

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: using ssget to change from paperspace to model space
« Reply #9 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
« Last Edit: March 15, 2011, 10:51:16 AM by Lee Mac »

Dashmonkey

  • Newt
  • Posts: 29
  • (defun sleep nil nil)
Re: using ssget to change from paperspace to model space
« Reply #10 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:
I didn't break it, I swear! ...ok, I broke it.