waders 发表于 2022-7-6 08:34:40

Reactor to Grip_strectch and L

Hello all,
 
I'm pretty new to the reactor side of coding and I'm trying to make one that does a regenall after doing a grip_stretch to a polyline on a specific layer "a-area". This is what I've found so far. Thanks
 
(if (not *field-update*)
(setq *field-update*
(vlr-command-reactor "Field-Update" '((:vlr-commandended . field-regen)))
)
)
(defun field-regen ( reactor params )
(cond
( (equal params '("GRIP_STRETCH"))
(vla-regen
(setq *acdoc*
(cond ( *acdoc* )
( (vla-get-activedocument (vlax-get-acad-object)) )
)
)
acactiveviewport
)
)
)
(princ)
)

Lee Mac 发表于 2022-7-6 08:51:32

Here is a quick example for LWPolylines:
 

(vl-load-com)(if (null *grip-reactor*)   (setq *grip-reactor*       (vlr-command-reactor "grip-reactor"          '(               (:vlr-commandwillstart . grip-reactor-start)               (:vlr-commandended   . grip-reactor-end)               (:vlr-commandfailed    . grip-reactor-fail)               (:vlr-commandcancelled . grip-reactor-fail)         )       )   ))(defun grip-reactor-start ( reactor params / en in ss )   (if       (and         (wcmatch (strcase (car params)) "*GRIP_STRETCH")         (setq ss (cadr (ssgetfirst)))       )       (progn         (setq in -1)         (while               (and                   (null *willregen*)                   (setq en (ssname ss (setq in (1+ in))))               )               (setq *willregen*                   (and                     (eq "LWPOLYLINE" (cdr (assoc 0 (setq en (entget en)))))                     (eq "A-AREA" (strcase (cdr (assoc 8 en))))                   )               )         )       )   )   (princ))(defun grip-reactor-end ( reactor params )   (if       (and         (wcmatch (strcase (car params)) "*GRIP_STRETCH")         *willregen*       )       (progn         (vla-regen               (setq *acdoc*                   (cond                     (*acdoc*)                     ((vla-get-activedocument (vlax-get-acad-object)))                   )               )               acactiveviewport         )         (setq *willregen* nil)       )   )   (princ))(defun grip-reactor-fail ( reactor params )   (if *willregen*       (setq *willregen* nil)   )   (princ))

alanjt 发表于 2022-7-6 08:53:09

Out of curiosity, why do you need to regen if you grip edit LWPolylines on a particular layer?

waders 发表于 2022-7-6 09:05:28

We have a Room Tag Block w/ a square footage field linked to a polyline. So everytime we remodel a area and update are databases we modify that pline and if you do a regen it updates that field. So instead of regen everytime we do a grip_stretch it will only react we modifing a pline on a that layer. I hope that make sence. Thanks

alanjt 发表于 2022-7-6 09:16:47

Clear as mud. Fantastic idea.

waders 发表于 2022-7-6 09:25:32

Hey Lee, This seems to work. Thanks for your help. Now I just need to digest it. Thanks

SLW210 发表于 2022-7-6 09:27:38

Please read the CODE POSTING GUIDELINES and edit your post.

Lee Mac 发表于 2022-7-6 09:40:38

 
Good stuff, shout if you have questions
页: [1]
查看完整版本: Reactor to Grip_strectch and L