Jump to content

Recommended Posts

Posted

Hi.

I tryed to write a routine that select points and create a file with my desired format.

It includes a "while" loop that shown here. always I run the routine and end selection of points by pressing Enter, it returns this:

error: bad argument type: lselsetp nil

I can't understand that where is the mistake.

Please guide me.

Thanks.

 

 
(while 
 (princ "\nSelect Center Line Point: ")
 (setq ss1 (ssget '((0 . "point"))))
 (setq sl1 (sslength ss1))
 (repeat sl1
.
.
.
.
)
)

Posted

You routine will constantly loop, as princ always returns T,

 

Also, the selsetp error means your selectionset is nil, you need to check for a valid selectionset before working with it.

Posted
you need to check for a valid selectionset before working with it.

 

I 'm new in lisp programming.

what do you mean?

and how the loop can stop by pressing enter.

Posted

Perhaps something like:

 

(while
 (progn
   (princ "\nSelect Center Line Point: ")
   (setq ss (ssget '((0 . "POINT"))))
 )
...  Do something ...
)

Posted
Perhaps something like:

 

(while
 (progn
   (princ "\nSelect Center Line Point: ")
   (setq ss (ssget '((0 . "POINT"))))
 )
...  Do something ...
)

 

:D:):D You are Right my friend.

it is working perfect. i'm so thankful.

You are the best.

Posted

Another question...

is it meaningful in lisp??

 
(while
    ......some functions......
    (while
         ......some functions......
    )
    (while
         ......some functions......
    )
)

Posted

what is this error mean?

error: bad argument type: lentityp nil

Posted

Yes, you can nest functions in LISP.

 

lentityp nil ==> entity is nil

Posted
Yes, you can nest functions in LISP.

 

lentityp nil ==> entity is nil

 

my routine returns this error:bad argument type: lentityp nil

this is my code:

 
.......
(while 
 (progn
  (princ "\nSelect Center Line Point: ")
  (setq ss1 (ssget '((0 . "point"))))
 )
 (setq sl1 (sslength ss1))
 (repeat sl1
.........
)
 (right)
 (left)
.........
)
;---------------------------
(defun right()
 (princ "\nSelect Right Points: ")
 (setq ss2 (ssget '((0 . "point"))))
 (setq sl2 (sslength ss2))
 (repeat sl2
...........
 )
)
;----------------------------
(defun left()
 (princ "\nSelect Left Points: ")
 (setq ss3 (ssget '((0 . "point"))))
 (setq sl3 (sslength ss3))
 (repeat sl3
.............
 )
)

 

what is wrong??

Posted

As I have said, you need to check for a valid SelectionSet before continuing - but your error cannot be caused by the code you have posted.

Posted

Without testing, it looks as if you're not selecting a point with the ssget.

Posted

in the first time, the routine works properly.

but for second time, it returns the error, although i select 6 point as right point.

(ie. by selecting right points for second time and pressing enter, the error is shown).

Posted

i solved my problem.

thanks for helping.

Posted
What was the issue?

 

I just determine ss2 and ss3 in the last code i sent, as local.

cause in the first iteration, these variables get nil value by pressing enter. thus i decided to determine them as local in every iteration.

now it works properly without error.

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