shamsam1 Posted August 21, 2008 Posted August 21, 2008 i want write a script in autocad 2007.i am completely new to script.i want some script sample to run...lcurious to lrean scripting..but dotn know how to start Quote
tzframpton Posted August 21, 2008 Posted August 21, 2008 Here is a quick tutorial to get you started: http://thecadgeek.com/blog/2008/03/02/introduction-to-autocad-script-files/ Just remember that when creating a script, moving to a new line it's the same as pressing Enter at the Command Line in AutoCAD. A script can do anything you can do in the Command Line, so use it as a reference. It's actually very simple. Once you've created a script, save the file as a *.SCR file, and stype SCRIPT at the command line to execute it. And if you're talking about doing some real programming, then you want to look at AutoLISP and .NET for your advanced stuff. Quote
shamsam1 Posted August 21, 2008 Author Posted August 21, 2008 thanks . i have started to code... but stuck with small error i am tring to freeze some around 10 layer dring load.. please guide me in freezing multiple layers and also with the thraw layers..sample code will be grate.... Quote
tzframpton Posted August 21, 2008 Posted August 21, 2008 thanks . i have started to code... but stuck with small error i am tring to freeze some around 10 layer dring load.. please guide me in freezing multiple layers and also with the thraw layers..sample code will be grate.... Paste the code. Quote
fuccaro Posted August 21, 2008 Posted August 21, 2008 Once you've created a script, save the file as a *.SCR file, and stype SCRIPT at the command line to execute it. Or if you are in the Windows environment (I am sure you are ) just drag the script file in your drawing area. Quote
shamsam1 Posted August 22, 2008 Author Posted August 22, 2008 i use this code to free layers. layer freeze layer1,layer2,layer3,layer4 this is working fine but when i press f2 to check what is happening in command line i see this Command: layer Current layer: "0" Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: freeze Enter name list of layer(s) to freeze or : layer1,layer2,layer3,layer4 Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: Command: LAYER Current layer: "0" Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: so bit confused to see some repetition..i am doing some thing wrong Quote
shamsam1 Posted August 22, 2008 Author Posted August 22, 2008 i wanted to use this lisp to free and thaw layer but i don't know how to modify it. in this lisp it prompts to select objects to make it unvisible,,instead of prompt it it asks for layer name the it will work fine.. ex unvisible layer1,layer2,layer3.. help me to change this lisp code (defun c:unvisible(/ objLst objLst sucCount errCount) (vl-load-com) (princ "\n>> ") (if (setq objSet(ssget)) (progn (setq objLst (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex objSet)))) sucCount 0 errCount 0); end setq (foreach obj objLst (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-visible (list obj :vlax-false))) (setq errCount(1+ errCount)) (setq sucCount(1+ sucCount)) ); end if ); end foreach (princ (strcat "\n"(itoa sucCount) " becomes unvisible " (if(/= 0 errCount) (strcat ", " (itoa errCount) " were on locked layer! ") ""); end if ); end strcat ); end princ ); end progn ); end if (princ) ); end of c:unvisible (defun c:visible(/ objLst objLst sucCount errCount) (vl-load-com) (setq sucCount 0 errCount 0 objSet(ssget "_X" '((60 . 1))) ); end setq (if objSet (progn (setq objLst (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr(ssnamex objSet))))) (foreach obj objLst (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-visible (list obj :vlax-true))) (setq errCount(1+ errCount)) (setq sucCount(1+ sucCount)) ); end if ); end foreach (princ (strcat "\n"(itoa sucCount) " becomes visible " (if(/= 0 errCount) (strcat ", " (itoa errCount) " were on locked layer! ") ""); end if ); end strcat ); end princ ); end progn (princ "\n>> ") ); end if (princ) ); end of c:visible Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.