Hello - I have a reactor function below that only seems to work halfway. I have two entities being passed to the reactor, a line and a block. The reactor should adjust the line based on changes to either the line or the block. The reactor works fine if i move the block, but when moving the line it runs through the process and the changes are not made. It doesn't modify the line (entmod ENL) even though when i print out the values of ENL the values are correct.
Hopefully someone out there can explain to me why this is happening. As far as I am concerned it should work, but alas, I am no expert...
(defun adjustLine (notifier-object
reactor-object
parameter-list /
object-list
vla-object
EN EL ENL p1 p2)
;;Get list of objects
(setq object-list (vlr-owners reactor-object))
;;Loop through each object in list
(foreach vla-object object-list
;;Convert object reference to AutoLISP style
(setq EN (vlax-vla-object->ename vla-object)
EL (entget EN))
(cond ;;what type of entity is it?
((= (cdr (assoc 0 EL)) "LINE");;Is the entity a line?
(setq ENL EL);;save entity list of line
(setq p2 (cdr (assoc 11 ENL))));;line cond
('T
;;Otherwise it is the block so get the insertion point
(setq p1 (vlax-safearray->list
(vlax-variant-value
(vla-get-insertionpoint vla-object)
))));;block cond );;cond );;foreach
;;Find point p1 will be moved to
(setq p3 (polar p1
(angle p1 p2)
(* 0.20828125 scale)))
(princ "\nENL: ")(princ ENL) ;<---shows values before line is changed ;;replace values in entity list (setq ENL (subst (cons 10 p3) (assoc 10 ENL) ENL) ENL (subst (cons 11 p2) (assoc 11 ENL) ENL)) (entmod ENL);;update the line ;<---only works when block is moved, why not line? (princ "\n\nENL: ")(princ ENL) ;<---shows correct values why isn't line moved here? (princ)
)
Thanks if anyone knows!
kemp
Hopefully someone out there can explain to me why this is happening. As far as I am concerned it should work, but alas, I am no expert...
(defun adjustLine (notifier-object
reactor-object
parameter-list /
object-list
vla-object
EN EL ENL p1 p2)
;;Get list of objects
(setq object-list (vlr-owners reactor-object))
;;Loop through each object in list
(foreach vla-object object-list
;;Convert object reference to AutoLISP style
(setq EN (vlax-vla-object->ename vla-object)
EL (entget EN))
(cond ;;what type of entity is it?
((= (cdr (assoc 0 EL)) "LINE");;Is the entity a line?
(setq ENL EL);;save entity list of line
(setq p2 (cdr (assoc 11 ENL))));;line cond
('T
;;Otherwise it is the block so get the insertion point
(setq p1 (vlax-safearray->list
(vlax-variant-value
(vla-get-insertionpoint vla-object)
))));;block cond );;cond );;foreach
;;Find point p1 will be moved to
(setq p3 (polar p1
(angle p1 p2)
(* 0.20828125 scale)))
(princ "\nENL: ")(princ ENL) ;<---shows values before line is changed ;;replace values in entity list (setq ENL (subst (cons 10 p3) (assoc 10 ENL) ENL) ENL (subst (cons 11 p2) (assoc 11 ENL) ENL)) (entmod ENL);;update the line ;<---only works when block is moved, why not line? (princ "\n\nENL: ")(princ ENL) ;<---shows correct values why isn't line moved here? (princ)
)
Thanks if anyone knows!
kemp