DON'T run this code before reading this. Better yet don't run the code at all
.
I'm made a database reactor and I've broken one of the rules: Modifying the object that called the reactor. I've noticed that even if I use the database reactor and modify a line, the reactor is called like 20 times. For more complex geometry (like the dynamic block in this case), it can be called upwards of 30 times just for one small modification.
I could create an object reactor... but... that's a lot of work, and I run into the same issue: that is modifying the object that triggered the reactor, unless I make the tag a separate object.... which......... I've done in a past life. Let's just say I would probably bail and use a different means to achieve the end goal here.
So... have a quick look at this code (DON'T run it... unless you're extremely adventurous or want to tweak/play around). Will it work and there's just something I'm missing? Or per above is it doomed to fail? It will work but then sporadically I start getting all sorts of crazy error messages; it literally starts to behave similar to unsafe code, but I think (I think!!) ACAD will crash before any real damage is done. I'm only encouraging quick feedback as I might try a different approach altogether. I'd hate for someone to spend a massive amount of time on this unless it helps them out in some way as well.
I've attached a file to help demo what I'm doing.
(vlr-AcDb-Reactor "kCs-ObjectModifiedReactor" '
((:VLR-ObjectModified . OnObjectModified
))) (vlr-AcDb-Reactor "kCs-ObjectModifiedReactor" '
((:VLR-ObjectModified . OnObjectModified
))) )
) ; end if
(defun OnObjectModified
( _callingReactor _objectInfo
/ object
)
(if (= (vla
-get
-effectiveName object
) "#-TEST BLOCK") (UpdatePadFootingDescription object)
)
)
)
)
)
) ; end defun
; ---------------------------------------------------------------------------------------
(defun UpdatePadFootingDescription
( _obj
/ )
(EditAttributeValue "TEST_TAG" (CreatePadFootingTextString _obj) _obj)
) ; end defun __________________________________________________________
; -----------------------------------------------------------------------
(defun EditAttributeValue
( _attTag _text _obj
/ )
)
)
)
) ; end defun __________________________________________
; --------------------------------------------------------------------
(defun GetDynamicBlockPropertyValue
(_propName _obj
/ propValue
)
(setq propValue
-1) ; *** if this is not changed, it means there is an error.
)
)
)
) ; end defun _____________________________________________________________
(defun CreatePadFootingTextString
( _obj
/ lengthString widthString depthString textString
)
(setq lengthString
(ConvertInchesToFeetToString
(GetDynamicBlockPropertyValue
"Length" _obj
))) (setq widthString
(ConvertInchesToFeetToString
(GetDynamicBlockPropertyValue
"Width" _obj
))) (setq depthString
(ConvertInchesToFeetToString
(GetDynamicBlockPropertyValue
"Depth" _obj
)))
(setq textString
(strcat lengthString
"' x " widthString
"' x " depthString
"' dp. Pad Footing"))
) ; end defun _________________________________________________________________________________
(defun ConvertInchesToFeetToString
( _input
/ )
) ; end defun _________________________________