Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted
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

Posted

I probably can not help, but post a sample dwg so others can look at it.

Posted

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

 

 

Posted (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 by mhupp

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...