Jump to content
wimal

Why the first code not working

Recommended Posts

(setq ss nil)
(if (and (not (initget "Lap"))
         (setq ss (entsel "\nSelect fixed line [Lap length] : ")))
         (if (= "Lap" ss)(progn
          (setq pick "Y")
   (setq ss (entsel "\nSelect fixed line  : "))
   )))

 

2nd code is working

 

(setq ss nil)
(if (and (not (initget "Lap"))
         (setq ss (getpoint "\npick point [Lap length] : ")))
         (if (= "Lap" ss)(progn
          (setq pick "Y")
   (setq ss (getpoint "\npick point  : "))
   )))

Edited by wimal
spell mistake

Share this post


Link to post
Share on other sites

I have never used initget with entsel or getpoint...

What are you trying to achieve? Im sure there is a simpler way...

Share this post


Link to post
Share on other sites
I have never used initget with entsel or getpoint...

What are you trying to achieve? Im sure there is a simpler way...

 

I need to allow to user to set value of LAP , if user required. Default value is set to 500

Share this post


Link to post
Share on other sites

And you want the user to be able to set the value of LAP... by selecting an entitie and get its length?

so 'LAP' is 500 OR the length of a selected line?

Share this post


Link to post
Share on other sites

Maybe the issue is related to the first letter of the keyword. 'L' has a special meaning when selecting entities: L=Last entity.

Share this post


Link to post
Share on other sites

Here is an example that checks what is picked. Includes L for last which is accepted by entsel.

 

(defun c:aaa ( / obj)
(while 
(setq obj (vlax-ename->vla-object (car (entsel "\nPick objects L for last object"))))
(cond
((= (vla-get-objectname obj) "AcDbLine")(setq len (vla-get-length obj)))
((= (vla-get-objectname obj) "AcDbArc")(setq len (vla-get-Arclength obj)))
((= (vla-get-objectname obj) "AcDbCircle")(setq len (vla-get-Circumference obj)))
((= (vla-get-objectname obj) "AcDbPolyline")(setq len (vla-get-length obj)))
)
(if (>  len 0.0)
(alert (strcat "length is " (rtos len 2 2)))
(alert "object has no direct length")
)
(setq len nil)
)
)

Share this post


Link to post
Share on other sites
Maybe the issue is related to the first letter of the keyword. 'L' has a special meaning when selecting entities: L=Last entity.

 

You are right, Its happening because of L stands for Last entity.

 

Check out this :

(setq ss nil)
(if (and (not (initget "LAP"))
 (setq ss (entsel "\nSelect fixed line [LAP length] : "))
   )
 (if (= "LAP" ss)
   (progn
     (setq pick "Y")
     (setq ss (entsel "\nSelect fixed line  : "))
   )
 )
)

Share this post


Link to post
Share on other sites
Maybe the issue is related to the first letter of the keyword. 'L' has a special meaning when selecting entities: L=Last entity.

 

Yes my friend ,it was the problem. Thanks a lot.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×