How to get this lisp accept numbers like 0.5 15.5 etc

How to get this lisp accept numbers like 0.5 15.5 etc

Anonymous
Not applicable
1,052 Views
5 Replies
Message 1 of 6

How to get this lisp accept numbers like 0.5 15.5 etc

Anonymous
Not applicable

in this lisp any of above numbers gifs a error "Requires an integer value." 

but I want the option to put in half meters of les like 0.2 ore 15.1 etc

I think the problem is in the getint but don't know what tot replace it with

(defun C:pld ()
            
            (setq segmentlengte (getint "\nput in distance: "))
            (setq lijn (getpoint "\nClick a line: "))
 	            
            (command "measure" lijn "b" blocknaam "y" segmentlengte)
		(setq blocknaam "rkaFF")) 
(while (/= lijn nill)
            (setq lijn (getpoint "\nclick line or enter to close: "))
            (if (/= lijn nill)(command "measure" lijn "b" blocknaam "y" segmentlengte)())
   )(princ)
)
0 Likes
Accepted solutions (3)
1,053 Views
5 Replies
Replies (5)
Message 2 of 6

Moshe-A
Mentor
Mentor
Accepted solution

@Anonymous hi,

 

replace (getint) with (getreal)

0 Likes
Message 3 of 6

_gile
Consultant
Consultant
Accepted solution

Hi

 

Or, better, replace (getint ...) with (getdist ...) so that the user can also specify the distance by clicking two points on screen.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

The code, as it is, doesn't work du toe extra right parenthesis, nill should be spelled as just nil... or you could omit at all.

 

(defun c:PLD (/ len blk ent)
  
  (setq len (getdist "\nput in distance: ")
	blk "rkaFF")
  (while (setq ent (entsel "\nselect line or <close>: "))
    (command "_.measure" ent "_block" blk "_yes" len))
  (princ)
)
Message 5 of 6

dbhunia
Advisor
Advisor

What I get from your code.......... You want to play with two blocks ("blocknaam" and "rkaFF") .......If so then your code should be like.....

 

(defun C:pld ()
            
        (setq segmentlengte (getdist "\nput in distance: "))
        ;(setq lijn (getpoint "\nClick a line: "))
	(setq lijn (car(entsel "\nClick a line: ")))

        (command "measure" lijn "b" "blocknaam" "y" segmentlengte)
	(setq blocknaam "rkaFF")

	(while (/= lijn nill)
            ;(setq lijn (getpoint "\nclick line or enter to close: "))
	    (setq lijn (car(entsel "\nclick line or enter to close: ")))
            (if (/= lijn nill)
		(command "measure" lijn "b" blocknaam "y" segmentlengte)
	    )
   	)
(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 6 of 6

Anonymous
Not applicable
(defun c:PLD (/ len blk ent)
  
  (setq len (getdist "\nput in distance: ")
	blk "rkaFF")
  (while (setq ent (entsel "\nselect line or <close>: "))
    (command "_.measure" ent "_block" blk "_yes" len))
  (princ)
)

above code is what 

This is what I like, even shorter code and it works perfect.
I accept the others also as solution because that was what i was asking for.
But you made the code perfect

 

thx
Remo