Author Topic: scripting questions  (Read 4320 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
scripting questions
« 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

daron

  • Guest
Re: scripting questions
« Reply #1 on: February 01, 2008, 02:32:31 PM »
(command ".-layer" "s" "0") or (setvar 'clayer 0) for starters.

ELOQUINTET

  • Guest
Re: scripting questions
« Reply #2 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

daron

  • Guest
Re: scripting questions
« Reply #3 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.

ELOQUINTET

  • Guest
Re: scripting questions
« Reply #4 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

ELOQUINTET

  • Guest
Re: scripting questions
« Reply #5 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...

daron

  • Guest
Re: scripting questions
« Reply #6 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?

ELOQUINTET

  • Guest
Re: scripting questions
« Reply #7 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

daron

  • Guest
Re: scripting questions
« Reply #8 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<< for how to lump it all into one call. Hint: replace NOT with OR

ronjonp

  • Needs a day job
  • Posts: 7531
Re: scripting questions
« Reply #9 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)
)
« Last Edit: February 01, 2008, 05:41:02 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ELOQUINTET

  • Guest
Re: scripting questions
« Reply #10 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")
)
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: scripting questions
« Reply #11 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: scripting questions
« Reply #12 on: February 01, 2008, 05:11:03 PM »
Just make sure the layout name is Model.

Are you seeing if we're awake Tim?

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

T.Willey

  • Needs a day job
  • Posts: 5251
Re: scripting questions
« Reply #13 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:
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ELOQUINTET

  • Guest
Re: scripting questions
« Reply #14 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: