after debugging my program, I finally got rid of the "too few arguments statment" foreach was messing me up so i reformatted my loop statement.
Now that it runs, I noticed the program only returns "-1" Is there anything I missed in my loop statement?any advice would be most helpful.
Code:
(defun c:AS3 (/ ent val cfm)
;; Define function, declare local variables
(if ;; If the following expression returns a non-nil value
(setq ent ;; Assign the value returned by the following expression to the symbol 'sel'
(ssget ;; Prompt the user to make a selection and return the selection set if successful
'
((0 . "INSERT"))
;; Filter the selection to block references only (INSERTs)
)
;; end ssget
)
;; end setq
(Setq I -1)
(While (setq ent (ssname val (setq I (1+ I))))
(setq val (LM:Tag_Val (vlax-ename->vla-object ent) "CFM"))
(Cond
;If
((>= val 51)
(<= val 0)
(LM:reprop "sort" "01" ent)
)
;Else
((>= val 76)
(<= val 52)
(LM:reprop "sort" "02" ent)
)
;Else
((>= val 121)
(<= val 77)
(LM:reprop "sort" "03" ent)
)
((>= val 176)
(<= val 122)
(LM:reprop "sort" "04" ent)
)
((>= val 177)
(LM:reprop "sort" "05" ent)
)
) ;End cond
(defun LM:reprop (blk lst / itm)
(setq
lst (mapcar '(lambda (x) (cons (strcase (car x)) (cdr x)))
lst
)
)
(foreach x (vlax-invoke blk 'getdynamicblockproperties)
(if (setq itm (assoc (strcase (vla-get-propertyname x)) lst))
(vla-put-value
x
(vlax-make-variant
(cdr itm)
(vlax-variant-type (vla-get-value x))
)
)
)
)
)
(defun LM:Tag_Val (blk tag)
(setq tag (strcase tag))
(vl-some '(lambda (att)
(if (= tag (strcase (vla-get-tagstring att)))
(atoi (vla-get-TextString att))
)
)
(vlax-invoke blk 'getattributes)
)
)
)
)
)