Jump to content

Customizing acaddoc.lsp


eric_monceaux

Recommended Posts

OK. I do believe it is good to go now. Thanks again alanjt and StykFacE...you guys are always helpful! Just for S&G's I have posted the final LSP. Considering what I have seen, this is nothing compaired to where I hope to eventually be, but it will do for now.

 

;;;
;;; 
;;;North American Stone Drawing Set Up
;;;Assisted
;;;alanjt and StykFacE assisted in the code writing
;;;---------------------
;;;ENVIRONMENT
(setvar "CMDECHO" 0)
(command "graphscr")
(command "base" "0,0,0")
(setvar "osmode" 6255)
(command "-INSERT" "Z_STD_SETUP=" nil)
(command "ERASE" "L" "")
(command "-STYLE" "SHEET" "tahoma.TTF" "0" "1" "0" "N" "N")
(if (tblsearch "layer" "0-STONE")
 (command "-LAYER" "_T" "0-STONE" "S" "0-STONE" "")
 (command "_.-layer" "_m" "0-STONE" "" "")
 )

(and (tblsearch "dimstyle" "24")
    (command "-DIMSTYLE" "R" "24")
    )
(command "LTSCALE" "6")
(command "PDMODE" "3")
(command "PDSIZE" "0")
(command "-HATCH" "P" "AR-SAND" "0.25" "0" "")
(command "INSUNITS" "1")
(command "LUNITS" "4")
(command "LUPREC" "4")
(command "AUNITS" "0")
(command "AUPREC" "0")
(command "VIEWRES" "Y""20000")
(command "SPLINESEGS" "20")
(command "FACETRES" "10")
(command "ISOLINES" "20")
(command "grid" "off")
(setvar "CMDECHO" 1);;;---------------------

Link to comment
Share on other sites

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • eric_monceaux

    12

  • alanjt

    11

  • tzframpton

    3

  • rkmcswain

    2

Top Posters In This Topic

Posted Images

Oops...can't believe I missed that.

 

What is the difference between using command vs. setvar?

 

Speaking of that...one of the reasons I really want to learn LISP is because it has more capabilities that standard macros. Granted I can write some pretty complicated macros, its process is more limited.

 

My plan is to learn how to change my macros into LISP, and then see what I can do to make them better. Example:

*^C^Cmline;st;standard;s;.25;j;z;\\;xplode;l;;la;mortar;

 

I know it's simple, but it helped get rid of a severly redundant task. What I dislike about macros (until I discovered custom Keybord Shortcuts) was that I only know how to make them buttons. I consider myself a bit old school, so typing comes more natural to me than icons.

 

Anyway, back to my question...what would do to turn this one into a lisp? I am sure there is a better way....like having the lisp generate a line on a specified layer offset from the users center pick point. Or, you might say, "why not just use mline?" Our use for it turns it into more of a chorus task...

Link to comment
Share on other sites

Much faster, cleaner, less typing, no echo to commandline.

 

Test to show difference.

Command: (benchmark '( (command "clayer" "alan") (setvar "clayer" "alan") ))
Elapsed milliseconds / relative speed for 2048 iteration(s):
   (SETVAR "clayer" "alan")......1266 / 4.43 <fastest>
   (COMMAND "clayer" "alan").....5609 / 1 <slowest>

Link to comment
Share on other sites

What is the difference between using command vs. setvar?

command executes a native AutoCAD command. setvar just sets a drawing and/or registry variable.

 

*EDIT* and once again I've been outdone by Alan. hehe 8) I like his explanation better.

Link to comment
Share on other sites

command executes a native AutoCAD command. setvar just sets a drawing and/or registry variable.

 

*EDIT* and once again I've been outdone by Alan. hehe 8) I like his explanation better.

 

Yours was a more educated response.

 

With our responses combined, we formed Captain Autocad.

 

Dork test achievement if you get that reference. LoL It depresses me that I made it.

Link to comment
Share on other sites

Better Captain AutoCAD than Captain Planet...I don't think AutoCAD has any....heart power...lol.

 

So, what would be the best way to write that macro into a LISP?

 

 

And I am all kinds of dork. Cool....but still dork.

Link to comment
Share on other sites

Better Captain AutoCAD than Captain Planet...I don't think AutoCAD has any....heart power...lol.

 

So, what would be the best way to write that macro into a LISP?

 

 

And I am all kinds of dork. Cool....but still dork.

 

 

 

DORK!!!

 

(defun c:TEst (/ #Entlast)
 (setq #Entlast (entlast))

 (command "_.mline" "_st" "Standard" "_s" 0.25 "_j" "_z")
 (while (> (getvar 'cmdactive) 0)
   (princ "\nSpecify next point: ")
   (command PAUSE)
 ) ;_ while

 (and (not (eq #Entlast (entlast)))
      (or (tblsearch "layer" "Mortar") (alert "Mortar layer does not exist!"))
      (progn
        (command "_.change" (entlast) "" "_p" "_la" "Mortar" "")
        (command "_.explode" (entlast))
      ) ;_ progn
 ) ;_ and

 (princ)
) ;_ defun

 

Had to ditch the use of XPlode, since it's not a core command.

Link to comment
Share on other sites

Don't get me started on the dorkiness stuff I know! I'll give you points if you know about the fizz of Cuckoo Cola...

 

Anywho, I am gonna pick this LISP apart....for learning purposes. (hope you aren't tired of me yet)

 

Firstly, it doesn't need to be a continous command. It just requires the user to pick two points and done. So, attempting to find that in the code...entlast tells CAD to repeat the command?

 

I get the flow of what you have written, however some of the symbol usage is confusing...i.e. # (> ) ;_

 

'cmdactive is saying to perform the following script on the command line only?

 

Other than that, I am a bit lost, but I think I have a window of opportunity today to run through some tutorials.

 

Thanks again!

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...