EYNLLIB Posted Friday at 12:02 AM Posted Friday at 12:02 AM I'm attempting to make a block with an attribute/field that when placed inside a pre-defined set of 4 coordinates (rectangle), the attribute field will update with a custom message. Anyone have any guidance with this? I'm guessing it will need a diesel expression, which I'm not all that familiar with. I'm hoping this is the right forum since it involves coding an expression Thanks Quote
BIGAL Posted Friday at 04:04 AM Posted Friday at 04:04 AM So if understand correctly you want to place a field value which says "This is inside area1 " You can certainly do as a lisp updating a value but not as a field. Not sure if you can do a COND in a field expression say looking at a multiple XY points. Quote
EYNLLIB Posted Friday at 04:13 AM Author Posted Friday at 04:13 AM 7 minutes ago, BIGAL said: So if understand correctly you want to place a field value which says "This is inside area1 " You can certainly do as a lisp updating a value but not as a field. Not sure if you can do a COND in a field expression say looking at a multiple XY points. Yeah, I can easily do a lisp but I don't want to have my engineers have to run a lisp every time for this workflow. I'm trying to have detail numbers auto populate based on where the detail title is located. So if the detail title attribute is in a specific area of model space, it will always be 1/S3.0, etc Quote
BIGAL Posted Friday at 04:39 AM Posted Friday at 04:39 AM I probably can not help, but post a sample dwg so others can look at it. Quote
Danielm103 Posted Friday at 08:38 AM Posted Friday at 08:38 AM Nothing I can think of that’s built in, so you would have to roll something. With lisp, you would use an event to update the attributes, i.e. attached to regen There’s more options with ARX, .NET or Python - Create your own custom field - Create an Overrule that updates the attributes on close Quote
mhupp Posted Friday at 01:08 PM Posted Friday at 01:08 PM (edited) 9 hours ago, EYNLLIB said: Yeah, I can easily do a lisp but I don't want to have my engineers have to run a lisp every time for this workflow. I'm trying to have detail numbers auto populate based on where the detail title is located. So if the detail title attribute is in a specific area of model space, it will always be 1/S3.0, etc Have you looked into reactors to trigger the lisp? Never really used them didn't like the fact something is running without me knowing/realizing it. (defun block-modified-callback (reactor obj) (let* ( (ent (vlr-object-reactor-object reactor)) (pos (cdr (assoc 10 (entget ent)))) ) ;; Define your target area (example: lower-left (0,0), upper-right (10,10)) (if (and (>= (car pos) 0) (<= (car pos) 10) (>= (cadr pos) 0) (<= (cadr pos) 10) ) (princ "\nBlock moved into target area!") ;call lisp ? (princ "\nBlock moved outside target area.") ; ) ) ) (defun C:BlockReact ( / ss i ent obj) (setq ss (ssget "_X" '((0 . "INSERT")))) ;maybe limit to the blocks you want to update (if ss (progn (setq i 0) (while (< i (sslength ss)) (setq ent (ssname ss i)) (setq obj (vlr-object-reactor (vlax-ename->vla-object ent) nil '((:vlr-modified . block-modified-callback)))) (setq i (1+ i)) ) (princ "\nReactors attached to block references.") ) (princ "\nNo blocks found.") ) (princ) ) -Edit Would have to run this after ever copy or insert of a block to add a reactor to it. and i don't know how this affect the performance of the drawing. Edited Friday at 01:40 PM by mhupp Quote
EYNLLIB Posted Friday at 03:44 PM Author Posted Friday at 03:44 PM 2 hours ago, mhupp said: Have you looked into reactors to trigger the lisp? Never really used them didn't like the fact something is running without me knowing/realizing it. (defun block-modified-callback (reactor obj) (let* ( (ent (vlr-object-reactor-object reactor)) (pos (cdr (assoc 10 (entget ent)))) ) ;; Define your target area (example: lower-left (0,0), upper-right (10,10)) (if (and (>= (car pos) 0) (<= (car pos) 10) (>= (cadr pos) 0) (<= (cadr pos) 10) ) (princ "\nBlock moved into target area!") ;call lisp ? (princ "\nBlock moved outside target area.") ; ) ) ) (defun C:BlockReact ( / ss i ent obj) (setq ss (ssget "_X" '((0 . "INSERT")))) ;maybe limit to the blocks you want to update (if ss (progn (setq i 0) (while (< i (sslength ss)) (setq ent (ssname ss i)) (setq obj (vlr-object-reactor (vlax-ename->vla-object ent) nil '((:vlr-modified . block-modified-callback)))) (setq i (1+ i)) ) (princ "\nReactors attached to block references.") ) (princ "\nNo blocks found.") ) (princ) ) -Edit Would have to run this after ever copy or insert of a block to add a reactor to it. and i don't know how this affect the performance of the drawing. I've never worked with reactors. I'll have to dig into it. Thanks! Quote
Lee Mac Posted 15 hours ago Posted 15 hours ago 20 hours ago, mhupp said: Have you looked into reactors to trigger the lisp? Never really used them didn't like the fact something is running without me knowing/realizing it. (defun block-modified-callback (reactor obj) (let* ( (ent (vlr-object-reactor-object reactor)) (pos (cdr (assoc 10 (entget ent)))) ) ;; Define your target area (example: lower-left (0,0), upper-right (10,10)) (if (and (>= (car pos) 0) (<= (car pos) 10) (>= (cadr pos) 0) (<= (cadr pos) 10) ) (princ "\nBlock moved into target area!") ;call lisp ? (princ "\nBlock moved outside target area.") ; ) ) ) (defun C:BlockReact ( / ss i ent obj) (setq ss (ssget "_X" '((0 . "INSERT")))) ;maybe limit to the blocks you want to update (if ss (progn (setq i 0) (while (< i (sslength ss)) (setq ent (ssname ss i)) (setq obj (vlr-object-reactor (vlax-ename->vla-object ent) nil '((:vlr-modified . block-modified-callback)))) (setq i (1+ i)) ) (princ "\nReactors attached to block references.") ) (princ "\nNo blocks found.") ) (princ) ) -Edit Would have to run this after ever copy or insert of a block to add a reactor to it. and i don't know how this affect the performance of the drawing. Don't create a new reactor for every object - this is likely to severely impact performance - only one object reactor is required with a set of owning objects. Aside, you're missing the definition for your (let*) function. 1 Quote
BIGAL Posted 1 hour ago Posted 1 hour ago If you use a reactor it is a lisp anyway and has to be ran every time you add the block, so as I suggested much easier to do a lisp that looks at the XY point and updates, a lisp will run through multiple blocks very fast and update all. Just make the lisp insert the block 1st. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.