PDA

View Full Version : Display value during routine


kaleksiejczyk
2008-07-22, 05:39 PM
Hello,

I have the following lisp that works well for us but we are looking to edit it slightly:



(defun C:/ ()
(setvar "cmdecho" 1)
(setq p1 (getpoint "\nPick Point 1:"))
(setq p2 (getpoint "\nPick Point 2:"))
(setq val1 (distance p1 p2))
(setq val2 (getreal "Second number to be divided: "))
(setq val3 (/ val1 val2))
(command "offset" val3)
)



This is one of the lisps from cadalyst I do believe. Its a lisp that allows us to divide a selected distance "val1 (distance p1 p2)" by a certain number "Second number to be divided" and then dump that into the offset command. Rather simple all in all.

Now what we are looking for is to view VAL1 before we enter "Second number to be divided". Basically we are looking to select the space between two lines and then decide on the number of equal spaces we need by seeing VAL1. Currently we need to use the distance command, view the distance between these two lines, then invoke the / command above. I would like to skip the whole distance command part and just use the / command outlined here. I have tried several things but nothing has worked.

Thank you all for any assistance you can give me.

KA

tedg
2008-07-22, 07:16 PM
Welcome to AUGI!!
Sorry, I don't have an answer for you, but I wanted to congratulate you on a nicely written "first post" with [code tags] and everything!

(most newbies don't get that first time, myself included)

:beer:

ccowgill
2008-07-22, 07:46 PM
Hello,

I have the following lisp that works well for us but we are looking to edit it slightly:



(defun C:/ ()
(setvar "cmdecho" 1)
(setq p1 (getpoint "\nPick Point 1:"))
(setq p2 (getpoint "\nPick Point 2:"))
(setq val1 (distance p1 p2))
(prompt (strcat "\n Distance:" (rtos val1 2 2) "\n"))
(setq val2 (getreal "Second number to be divided: "))
(setq val3 (/ val1 val2))
(command "offset" val3)
)

This is one of the lisps from cadalyst I do believe. Its a lisp that allows us to divide a selected distance "val1 (distance p1 p2)" by a certain number "Second number to be divided" and then dump that into the offset command. Rather simple all in all.

Now what we are looking for is to view VAL1 before we enter "Second number to be divided". Basically we are looking to select the space between two lines and then decide on the number of equal spaces we need by seeing VAL1. Currently we need to use the distance command, view the distance between these two lines, then invoke the / command above. I would like to skip the whole distance command part and just use the / command outlined here. I have tried several things but nothing has worked.

Thank you all for any assistance you can give me.

KA
try the above changes in red

Opie
2008-07-22, 07:54 PM
Look at the rtos AutoLISP function as in:
(rtos val1 (getvar "lunits")(getvar "luprec"))

Tom Beauford
2008-07-23, 03:52 PM
This will allow you the option of entering the distance, display it while asking what to divide it by, and draw that many offset lines:
(defun C:/ (/ val1 val2 val3 ss p1)
(setvar "cmdecho" 0)
(prompt "Specify a distance by entering a number or by selecting two points: ")
(setq val1 (getdist))
(setq val2 (getint (strcat "Divide " (rtos val1) " by: ")))
(setq val3 (/ val1 val2))
(prompt "Select object to offset: ")
(setq ss (ssget "+.:E:S" '((0 . "lwpolyline,polyline,line,arc,spline,circle,ellipse"))))
(setq p1 (getpoint "\nSpecify point on side to offset beyond needed offset lines: "))
(command "offset" val3 (ssname ss 0) p1 "Exit")
(repeat (- val2 1) (command "offset" val3 (entlast) p1 "Exit"))
(princ)
)

kaleksiejczyk
2008-07-24, 10:30 PM
Welcome to AUGI!!
Sorry, I don't have an answer for you, but I wanted to congratulate you on a nicely written "first post" with [code tags] and everything!

(most newbies don't get that first time, myself included)

:beer:

Ted,

Thanks man. We all do what we can, even some newbs. See you around the forums.



Chris, Opie, Tom,

Thank you to each of you. You have given me some solid info and I think it will help more than just this one routine that is now fixed. I appreciate the help.

KA