TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jlogan02 on March 13, 2020, 05:07:24 PM
-
I'm missing something....
bad argument type lselsetp nil...
(defun c:foo1
( / selset i s x
) (if (setq selset
(ssget "_X" '
((0 .
"DIMENSION") (3 .
"DIMEN_NEW")))) )
)
)
)
)
)
Trying to move placed dimensions from "DIMEN_NEW" dimstyle to "DIMEN" dimstyle.
-
I don't have any applicable test data but this should work (in theory) while illuminating a couple defensive strategies:
(defun foo ( old_style new_style / ss i c pair ename data )
(cond
( (null (tblsearch "dimstyle" (setq new_style (strcase new_style))))
(princ (strcat "\nError: New dimstyle <" new_style "> does not exist."))
)
( (null (setq ss (ssget "_x" (list '(0 . "dimension") (cons 3 (setq old_style (strcase old_style)))))))
(princ (strcat "\nNo dimensions sporting dimstyle <" old_style ">."))
)
( (setq c 0 pair (cons 3 new_style))
(repeat (setq i (sslength ss))
(vl-catch-all-apply 'entmod
(list
(subst
pair
(assoc 3 (setq data (entget (setq ename (ssname ss (setq i (1- i)))))))
data
)
)
)
(if (eq new_style (strcase (cdr (assoc 3 (entget ename)))))
(setq c (1+ c))
)
)
(princ (strcat "\nSuccessfully changed <" (itoa c) "> dim entities to dimstyle <" new_style ">."))
)
)
(princ)
)
(defun c:foo ( )
(foo "dimen_new" "dimen")
)
-
The error means your selection set is empty. http://www.lee-mac.com/errormessages.html (http://www.lee-mac.com/errormessages.html)
Perhaps the sslength and the ssname functions should point to selset and not s
(defun c:foo1
( / selset i s x
) (if (setq selset
(ssget "_X" '
((0 .
"DIMENSION") (3 .
"DIMEN_NEW")))) )
)
)
)
)
)
-
I respectfully submit there are bigger issues than an empty selection set. For starters you don't iterate selection sets via the foreach function ...