bababarghi Posted April 24, 2017 Share Posted April 24, 2017 Hi all, I am getting error: bad argument type: lentityp by running following code: (defun ATR ( handSTR) (if (HANDENT handSTR) (progn (setq ss1 (ssadd handSTR)) (command ".attedit" "y" "*" "*" "*" ss1 "color" "t" "255,0,0" "n") (ssdel handSTR ss1) ) ) (princ) ) (ATR "543B") What am I doing wrong here? Quote Link to comment Share on other sites More sharing options...
Grrr Posted April 24, 2017 Share Posted April 24, 2017 _$ (handent nil) Error: bad argument type: stringp nil _1$ So use: (and (eq 'STR (type handent)) (handent handSTR)) instead of: (HANDENT handSTR) EDIT: Oh, and the actual reason for the error: Change: (setq ss1 (ssadd handSTR)) To: (setq ss1 (ssadd (handent handSTR))) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 24, 2017 Share Posted April 24, 2017 I would also suggest testing whether (entget (handent )) returns a non-nil value (i.e. testing whether the entity is erased), as handent can return the entity name for entities for which the erase flag is set. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted April 24, 2017 Share Posted April 24, 2017 ... Or use vlax-erased-p (faster than entget). Quote Link to comment Share on other sites More sharing options...
Grrr Posted April 24, 2017 Share Posted April 24, 2017 I also think that it would be good to include this part to the checklist (wrapped within and function): (setq ss1 (ssadd (handent handSTR))) And use progn for the command call and ssdel. To account non-graphical entity's handles: _$ (ssadd (handent (cdr (assoc 5 (entget (namedobjdict)))))) nil Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted April 24, 2017 Share Posted April 24, 2017 @Grrr: (equal (namedobjdict) (handent (cdr (assoc 5 (entget (namedobjdict)))))) => T I can't think of a scenario where I would want to add a non-graphical entity to a selection set. Quote Link to comment Share on other sites More sharing options...
Grrr Posted April 24, 2017 Share Posted April 24, 2017 @Grrr: (equal (namedobjdict) (handent (cdr (assoc 5 (entget (namedobjdict)))))) => T Overthinking. I can't think of a scenario where I would want to add a non-graphical entity to a selection set. We don't know how the OP collects the handles - so thats just small additional check, not a big deal and will evaluate anyways (with or without checking). Quote Link to comment Share on other sites More sharing options...
bababarghi Posted April 24, 2017 Author Share Posted April 24, 2017 Thanks all for your kind help. Problem resolved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.