TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ELOQUINTET on February 01, 2008, 02:26:38 PM

Title: scripting questions
Post by: ELOQUINTET on February 01, 2008, 02:26:38 PM
i'm trying to write a house cleaning script and cannot get a couple of things to work.

1) i am trying to set the layer 0 so i can purge out all unwanted layers.

I am using 2 methods layer set and clayer and neither one is changing the layer
Any thoughts as to why not?

-layer
set
0

clayer
0

2)
Iam also trying to set the current dimstyle to STANDARD for the same purposes but the dialogue box is halting the script not allowing me to purge, any thoughts?

-dimstyle
restore
STANDARD
Title: Re: scripting questions
Post by: daron on February 01, 2008, 02:32:31 PM
(command ".-layer" "s" "0") or (setvar 'clayer 0) for starters.
Title: Re: scripting questions
Post by: ELOQUINTET on February 01, 2008, 03:23:13 PM
this is from my text window?


Command: (command ".-layer" "s" "0")
.-layer
Current layer:  "_REVCLOUD070831"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
s
Enter layer name to make current or <select object>: 0 Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:
nil



Command: (setvar "clayer" 0)
; error: AutoCAD variable setting rejected: "clayer" 0
Title: Re: scripting questions
Post by: daron on February 01, 2008, 03:31:00 PM
try taking the quotes off "0"? I know 2008 made some commands a little goofy. Don't have it here, so I can't dig deeper for you.
Title: Re: scripting questions
Post by: ELOQUINTET on February 01, 2008, 03:31:54 PM
i figured out what was causing the layer to not change. I disabled this reactor that we were working on in this post  :roll:

http://www.theswamp.org/index.php?topic=21056.0 (http://www.theswamp.org/index.php?topic=21056.0)
Title: Re: scripting questions
Post by: ELOQUINTET on February 01, 2008, 03:35:04 PM
daron i'm actually now using adt 3.3 which i just changed in my profile  :cry: but we will be upgrading to 2007 soon, Real soon I hope...
Title: Re: scripting questions
Post by: daron on February 01, 2008, 03:43:13 PM
They should just wait 'til March and upgrade to '09 or at least go to '08. Wait? Why are you using ADT for Ralph Lauren? You drawing their buildings?
Title: Re: scripting questions
Post by: ELOQUINTET on February 01, 2008, 04:15:13 PM
daron i got the stuff i was asking about working but now i have another problem. i am trying to select all of the hatch, dimensions, leaders text and delete it. It is working if all exists in the drawing but if not then it halts. I'm guessing I need to wrap all of this inside of an if statement but not sure how. I'm also guessing these could all be combined but not sure how that should look. To answer your autocad questions. They won't upgrade to those versions because it has not had time to be "engineered" by out IT department. We are using adt but I guess they stripped away that functionality cause i don't see any of it on my screen. I think we will be switching to straight acad 07.

Code: [Select]
(setq d (ssget "x" '((0 . "hatch"))))
erase
!d

;select all notation and erase it
(setq d (ssget "x" '((0 . "dimension"))))
erase
!d

(setq d (ssget "x" '((0 . "leader"))))
erase
!d

(setq d (ssget "x" '((0 . "mtext"))))
erase
!d

(setq d (ssget "x" '((0 . "text"))))
erase
!d
Title: Re: scripting questions
Post by: daron on February 01, 2008, 04:28:17 PM
I don't want to lead you down the wrong path by not testing this idea, but I believe you can do an "or" statement. Look >>here<< (http://www.theswamp.org/index.php?topic=20300.0) for how to lump it all into one call. Hint: replace NOT with OR
Title: Re: scripting questions
Post by: ronjonp on February 01, 2008, 04:57:39 PM
Code: [Select]
(if (setq d (ssget "x" '((0 . "TEXT,MTEXT,LEADER,DIMENSION,HATCH"))))
  (command "._erase" d "")
)

Code: [Select]
(defun c:deletelayouts (/)
  (vlax-map-collection
    (vla-get-layouts
      (vla-get-ActiveDocument
(vlax-get-Acad-Object)
      )
    )
    '(lambda (x)
       (vl-catch-all-apply 'vla-delete (list x))
     )
  )
  (princ)
)
Title: Re: scripting questions
Post by: ELOQUINTET on February 01, 2008, 05:07:42 PM
i was trying this method daron but couldn't get it working, here's what i had.
i am using rons' but would still like to know the other way.
i have another question also. i need to delete all of the layouts in the drawing but don't see how i could do that throught a macro without speciying the name which may vary.


Code: [Select]
(ssget (list '(-4 . "<OR")
             '(0 . "hatch")
             '(0 . "dimension")
     '(0 . "leader")
     '(0 . "mtext")
     '(0 . "text")
             '(-4 . "<OR")
)
)
Title: Re: scripting questions
Post by: T.Willey on February 01, 2008, 05:10:02 PM
i have another question also. i need to delete all of the layouts in the drawing but don't see how i could do that throught a macro without speciying the name which may vary.
Just step through the layout collection and delete the layouts.  Not a problem.  Just make sure the layout name is Model.
Title: Re: scripting questions
Post by: MP on February 01, 2008, 05:11:03 PM
Just make sure the layout name is Model.

Are you seeing if we're awake Tim?

:)
Title: Re: scripting questions
Post by: T.Willey on February 01, 2008, 05:18:12 PM
Just make sure the layout name is Model.

Are you seeing if we're awake Tim?

:)
Nope.  Good catch, as I'm not awake.  Late night, and very little sleep.   :wink:
Title: Re: scripting questions
Post by: ELOQUINTET on February 01, 2008, 05:18:32 PM
uh i'm awake, barely, but don't know exactly how to look throught the layout collection. I think I've seen it done in some routines i have but never actually studied it. perhaps i'll investigate this weekend...or not  :lmao:
Title: Re: scripting questions
Post by: MP on February 01, 2008, 05:19:16 PM
Late night, and very little sleep.

You've my full sympathies Tim - take the rest of the day off!

Title: Re: scripting questions
Post by: daron on February 01, 2008, 05:47:14 PM
Just make sure the layout is not named Model. As for getting that other thing working, if you got Ron's working, that's all you need. I'm glad you want to understand the point list one, but I'm too far removed to remember and am way to tired to research it. Ohhh, this is going to be a long 45 minutes of work that I have left.
Title: Re: scripting questions
Post by: ronjonp on February 01, 2008, 05:49:03 PM
I updated my last post with code to delete all layouts.
Title: Re: scripting questions
Post by: T.Willey on February 01, 2008, 07:06:41 PM
Late night, and very little sleep.

You've my full sympathies Tim - take the rest of the day off!


Thanks.  If only I could.  At least it's only 40 more minutes.