Jump to content

Why the first code not working


wimal

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
Link to comment
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

Link to comment
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?

Link to comment
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)
)
)

Link to comment
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  : "))
   )
 )
)

Link to comment
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.

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