A question about reactor.

A question about reactor.

Anonymous
Not applicable
499 Views
2 Replies
Message 1 of 3

A question about reactor.

Anonymous
Not applicable

 

A question about reactor.  

See code:

Use "Leader" for dimension. with reactor . 

But when I delete that "leader" object.  will error. How can I fix this error. 

 

Thank you very much for help.

 

;; (_AddMleader (getpoint) (getpoint) "A" 3.5)
(defun _AddLeader (p1 p2 str Ang TextHeight / HANDLEM OBJL OBJM POINTS)
	(setq points (vlax-make-safearray vlax-vbDouble '(0 . 5)))
	(vlax-safearray-fill points (append P1 p2))
	;;(vla-AddMText modelSpace corner width text)
	(setq ObjM (vla-AddMText *MS* (vlax-3d-point p2) 1 str))
	;;Height AttachmentPoint Handle Width
	(vlax-put ObjM 'Height TextHeight)
	(vlax-put ObjM 'AttachmentPoint 7)
	(vlax-put ObjM 'Width 0);
	
	(cond ((> (atof (getvar "ACADVER")) 16) (vlax-put ObjM 'BackgroundFill 1)))
	(vlax-put ObjM 'Rotation Ang)
	(setq ObjL (vla-AddLeader *MS* points ObjM acLineNoArrow))
	(setq HandleM (vlax-get ObjM 'Handle))  
	;;(vlr-pers (VLR-Object-Reactor (list ObjL) (list HandleM) '((:VLR-modified . _LeaderModify))))
	(VLR-Object-Reactor (list ObjL) (list HandleM) '((:VLR-modified . _LeaderModify)))
	(list ObjM ObjL)
)

(defun _LeaderModify (ObjL ObjMList parameter-list / EL EM EN PTS STR)
	(setq eL (vlax-vla-object->ename ObjL))
	(setq pts (vlax-get ObjL 'Coordinates))
	(setq eM (handent (car (vlr-data ObjMList))))                  
	(setq en (entget em))
	(setq        str (strcat "X="
		(VL-PRINC-TO-STRING (cadr pts))
		"\\P"
		"Y="
		(VL-PRINC-TO-STRING (car pts))
	)
	)
	(entmod (subst (cons 1 str) (assoc 1 en) en))
)


(defun C:zbbz (/ ANS FLAG GR OBJ P1 P2 STR TEXTHEIGHT zbbz1 zbbz2)
	(defun zbbz1 ()
		(initget "S ")
		(setq p1 (getpoint "\n Point, or [Enter Angle S] <S>:"))
	)
	(defun zbbz2 ()
		(setq AnS (zbbz1))
		(cond
			((= AnS "S") (setq *Ang_ZBBZ* (getangle "\nText inclination angle")) (zbbz2))
			((= (type AnS) 'List)
				(princ "\nPlacement")
				(while (equal (setq p2 (cadr (grread T 8))) AnS TextHeight))
				(setq str (strcat "X="
					(VL-PRINC-TO-STRING (cadr AnS))
					"\\P"
					"Y="
					(VL-PRINC-TO-STRING (car AnS))
				)
				)
				(setq Obj (_AddLeader AnS p2 str *Ang_ZBBZ* TextHeight))
				;;(vlax-put ObjL 'Coordinates (append AnS p2))
				;;(vlax-put ObjM 'InsertionPoint p2)
				(while (and (setq gr (grread T 8)) (= (car gr) 5))
					(setq p2 (cadr gr))         
					(cond ((not(equal p2 AnS TextHeight))
						(vlax-put (car Obj) 'InsertionPoint p2)
						(vlax-put (cadr Obj) 'Coordinates (append AnS p2))
					)
					)
				)
			)
			(T (setq Flag nil))
		)
	)
	
	
	(vl-Load-COM)
	(or *ACAD* (setq *ACAD* (vlax-get-acad-object)))
	(or *DOC* (setq *DOC* (vla-get-ActiveDocument *ACAD*)))
	(or *MS* (setq *MS* (vla-get-modelSpace *DOC*)))
	
	(cond((not *Ang_ZBBZ*)(setq *Ang_ZBBZ* 0)))
	(SETQ TextHeight (* (GETVAR "DIMTXT") (GETVAR "DIMSCALE"))) 
	(setq Flag T)
	(while Flag (zbbz2))
	(princ)
)
0 Likes
500 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Lisp Master. Plaease help me have a look. Thank you.

0 Likes
Message 3 of 3

dbroad
Mentor
Mentor

When an object is deleted, it will fire the modified event.  Think about all the stuff you are doing to access a potentially deleted object.  First, check to see if it has been erased before getting data from it or before converting it to an ename.  Why are you converting the object to an ename in the callout?  What's with the strange argmument names?  (callback <object> <reactor> <list>).  You've mixed up the X and Y coordinates as well.

 

I would have used a dynamic block with fields to do this task.

Architect, Registered NC, VA, SC, & GA.
0 Likes