Jump to content

slope lisp needed


NH3man!

Recommended Posts

I can't for some reason get it to move the block now in any other direction but +x now. It gives me the prompt for all four but no matter which one I pick it move +X.

Link to comment
Share on other sites

  • Replies 70
  • Created
  • Last Reply

Top Posters In This Topic

  • NH3man!

    38

  • Lee Mac

    29

  • lpseifert

    1

  • Freerefill

    1

I take that back. It will move in the +Y also. But not the -Y and -X. Could this be a one of toughs syntacs things you were talking about.

Link to comment
Share on other sites

It all seems to work for me :)

 

I have added an UNDO to this one:

 

(defun c:hc  (/ *error* vlst ovar cBlk tmp1 tmp2 tmp3 tmp4 blkpt)

 ; Error Handler

 (defun *error*  (msg)
   (if ovar
     (mapcar 'setvar vlst ovar)) ; Return System Variables
   (if (not (member msg '("Function cancelled" "quit / exit abort")))
     (princ (strcat "\n<< Error: " msg " >>"))) ; Print Error Message
   (princ))

 ; Collect and Set System Variables

 (setq vlst '("CMDECHO" "OSMODE")
       ovar (mapcar 'getvar vlst))
 (mapcar 'setvar vlst '(0 0))

 ; Set Defaults

 (or hc$slp:def (setq hc$slp:def 1))
 (or hc$cop:def (setq hc$cop:def 1))
 (or hc$spc:def (setq hc$spc:def 1))
 (or hc$dir:def (setq hc$dir:def "X"))

 ; Get Block to Copy

 (if (and (setq cBlk (car (entsel "\nSelect Block: ")))
          (eq "INSERT" (cdr (assoc 0 (entget cBlk)))))
   (progn

 ; Get User Input

     (initget 6)
     (setq tmp1 (getreal (strcat "\nSpecify Slope <" (rtos hc$slp:def) "> : ")))
     (or (not tmp1) (setq hc$slp:def tmp1))
     (initget 6)
     (setq tmp2 (getint (strcat "\nSpecify Number of Copies <" (itoa hc$cop:def) "> : ")))
     (or (not tmp2) (setq hc$cop:def tmp2))
     (initget 6)
     (setq tmp3 (getreal (strcat "\nSpecify Spacing <" (rtos hc$spc:def) "> : ")))
     (or (not tmp3) (setq hc$spc:def tmp3))
     (initget "X Y -x -y")
     (setq tmp4 (getkword (strcat "\nSpecify Axis [X/Y/-X/-Y] <" hc$dir:def "> : ")))
     (or (not tmp4) (setq hc$dir:def tmp4))

 ; Get Block Insertion Point Information and Initiate Counter

     (setq blkpt (cdr (assoc 10 (entget cBlk)))
           i     1)

 ; Copy the Block a Number of Times
     (command "_undo" "_Begin")

     (repeat hc$cop:def

       (command "_copy" cBlk "" blkpt)
       (cond ((eq "X" hc$dir:def)
              (command
                (list (+ (* i hc$spc:def) (car blkpt))
                      (cadr blkpt)
                      (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt)))))
             ((eq "Y" hc$dir:def)
              (command
                (list (car blkpt)
                      (+ (* i hc$spc:def) (cadr blkpt))
                      (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt)))))
             ((eq "-x" hc$dir:def)
              (command
                (list (+ (* -1. i hc$spc:def) (car blkpt))
                      (cadr blkpt)
                      (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt)))))
             ((eq "-y" hc$dir:def)
              (command
                (list (car blkpt)
                      (+ (* -1. i hc$spc:def) (cadr blkpt))
                      (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt)))))
             ) ; end cond
       (command)
       (setq i (1+ i)))

     (command "_undo" "_End"))

 ; Else No Block was Selected

   (princ "\n<!> No Block Selected <!>"))

 ; Return Sys Vars Back

 (mapcar 'setvar vlst ovar)

 ; Exit Cleanly

 (princ))

 

Try reloading the code, and make sure you have this version loaded :)

Link to comment
Share on other sites

Here is what I found. As long as I type in the new direction on the command line it will move in that direction. But in I click in the prompt box it just takes the last function and uses it.

Link to comment
Share on other sites

Here is what I found. As long as I type in the new direction on the command line it will move in that direction. But in I click in the prompt box it just takes the last function and uses it.

 

Not sure about that - in '04 you can't click in the prompt box... :unsure:

Link to comment
Share on other sites

I can't at work either I disabled it. This laptop they gave me I hardly ever use so didn't really set the configuration as I like it.

 

Thanks again Lee.

 

PS I was up till 2 in the morning reading about all though lsp terms.

Link to comment
Share on other sites

PS I was up till 2 in the morning reading about all though lsp terms.

 

Nice one - if you need any clarification on anything, just ask :)

Link to comment
Share on other sites

(setq tmp4 (getkword (strcat "\nSpecify Axis [sZ] : ")))

(or (not tmp4) (setq hc$dir:def tmp4))

 

I ran into a problem sort of. I have found that I am not always moveing just the x or y direction. So I tried to edit the axis part of the prompt with an Alias I have for snap angle. I have tried to put in the regular command and my alias but can't seem to get it to work. What else am I missing to get this to go to the angle I have my snap and curser set at.

Link to comment
Share on other sites

(list (+ (* i hc$spc:def) (car blkpt))

(cadr blkpt)

(+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt)))))

 

Lee in this part of your code, I can't seem to figure out what the * and i are doing. I almost understand the rest. I am thinking it has something the starting point of the last block copied but at this point I am guessing.

Link to comment
Share on other sites

(list (+ (* i hc$spc:def) (car blkpt))

(cadr blkpt)

(+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt)))))

 

Lee in this part of your code, I can't seem to figure out what the * and i are doing. I almost understand the rest. I am thinking it has something the starting point of the last block copied but at this point I am guessing.

 

The i is incremented by 1 on every repeat, hence the block spacing is multiplied by this increment.

Link to comment
Share on other sites

Oh one more thing. Why won't the (rtos) accept a negetive numbuer> i.e. -.125

 

-.125 is not a real number - you need to specify -0.125

Link to comment
Share on other sites

I have used this today and it works like a champ. Lee if there is anything I can do for you I am willing. Not only for your hard work but for your teaching ability. You have mad me look into ACAD like I just started. I thank you for that.

 

Thank you,

NH3man!

Link to comment
Share on other sites

I have used this today and it works like a champ. Lee if there is anything I can do for you I am willing. Not only for your hard work but for your teaching ability. You have mad me look into ACAD like I just started. I thank you for that.

 

Thank you,

NH3man!

 

Thanks NH3man!,

Your thanks is sufficient repayment -

 

I'd be more than happy to answer any other questions regarding this, or any other code I have posted on this site - as it helps me learn more about it by teaching someone else :)

 

Thanks

 

Lee

Link to comment
Share on other sites

-.125 is not a real number - you need to specify -0.125

 

I tried entering it in like that and it say it has to be a non-negative number. It is not a big deal I always now which way the blocks need to slope.

Link to comment
Share on other sites

that is to do with the "initget" argument that I included to disallow negatives.

 

Change the correct (initget 6) to an (initget 2) to get around this.

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...