Author Topic: attribute 'linking'  (Read 8142 times)

0 Members and 1 Guest are viewing this topic.

rooster jk

  • Guest
attribute 'linking'
« on: April 27, 2011, 03:15:29 PM »
ok, so i started another topic that has lead me to believe i need to start this one...

has anyone found a way to link an object to an attribute?  lets say you have a block that you need to put an area of an object into.  so you have a rectangle as the object and you have a block that has an attribute in it that you want the value of to be linked to the rectangle's area.  so if and when you change the size of the rectangle that the attribute would update.  i have found a vlisp routine that will let me place a field that would be linked to the object so perhaps this is starting point?

really what i'm after isn't just related to the area, it's just an example.  what i'm really after is being able to link objects that have values to blocks that have attributes.

any ideas or suggestions would be greatly appreciated...

rooster jk

  • Guest
Re: attribute 'linking'
« Reply #1 on: April 27, 2011, 03:31:27 PM »
after reading this i have realized that to achomplish what i'm asking isn't that dif by using a field in the block att.  but what i'm tryhing to do is create a lisp routine that will run something like this...

USER: run lisp routine

CAD: select block that has attribute to be changed:

USER: select block that has the attribute that you want to update

CAD: which attribute do you wish to change?

USER: select from list the attribute that you want to update

CAD: select object to link to block

USER: select object with desired value of attribute

CAD: select object's value that you want to use to update attribute

USER: select object's value

CAD: updates the block attribute and returns to command line

hope this is more clear as to what i'm looking to achomplish

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: attribute 'linking'
« Reply #2 on: April 27, 2011, 03:40:30 PM »
Hi,

You can have a look at this thread, last release here.
Speaking English as a French Frog

T.Willey

  • Needs a day job
  • Posts: 5251
Re: attribute 'linking'
« Reply #3 on: April 27, 2011, 03:47:47 PM »
If you want to go the field route, then this code will help you out.
[ http://www.theswamp.org/index.php?topic=20446.0 ]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: attribute 'linking'
« Reply #4 on: April 27, 2011, 05:55:32 PM »
What are you referring to when you say 'Object's Value' ? Another attribute? An area? A Text Value?

rooster jk

  • Guest
Re: attribute 'linking'
« Reply #5 on: April 28, 2011, 12:49:53 AM »
yes object's value could be another att or an area or a vol...really anything that the object will produce as a value that is of use.  there is more than one thing i'm working on now.  first i was trying to be able to link a 3d solid or masselement's volume to an attribute in a title block, with the idea being that once they were linked the att would be updatable as the object changes.  i know how to use a field to acchomplish this but its time consuming and cumbersome to do so i'm trying to make it a more streamlined process.

i also am trying to be able to link a block with lots of attributes in it to a another block.  the idea here is that i have a block that has attributes in it that a user fills in.  i then would like to be able to take this block and 'link' it to another block where the values would be transfered if you will to the other block.  make any sense?  i know that with a field you can do this but again it's time consuming to do an edit and manually 'link' each att to the block.

thanks for any help.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: attribute 'linking'
« Reply #6 on: April 28, 2011, 05:09:16 AM »
A LISP program could certainly be written to create the fields for you following selection of the source object and object to house the field. Here is one such example.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: attribute 'linking'
« Reply #7 on: April 28, 2011, 10:54:31 AM »
Post a sample drawing. I'm a visual learner  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

rooster jk

  • Guest
Re: attribute 'linking'
« Reply #8 on: April 28, 2011, 02:30:11 PM »
A LISP program could certainly be written to create the fields for you following selection of the source object and object to house the field. Here is one such example.

what you have sent me to is exactly what i'm looking for, with the only real dif being that i would like it to get the volume from a 3d-solid or masselement.  one problem i have run across in trying to do this is that 3d solids volumes and masselements volume behave differently.  3d solids volume when retrieved from cad if you will only come in cubic inches, while masselements values come in whatever the volume units of the drawing are set to.  so i'm not sure if in the lisp routine that there would need to be something that changes the volume units setting to cubic inches so that if a 3d solid or masselement is selected that the output is consistent.  the reality is that the final product i'm looking for is cubic yards, but it's just math to change it from cubic inches.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: attribute 'linking'
« Reply #9 on: April 28, 2011, 02:57:59 PM »
Hi,

AFAIK, you won't get the volume (neither other 3d solid mechanic property) in a field.
You can only get it using the COM/ActiveX properties (vla-get-volume ...) and fill an attribute with the result, but if you want your attribute to be dynamically linked to the 3d solid, you'll have to use reactors as in the exammple in the link I provided.
Speaking English as a French Frog

rooster jk

  • Guest
Re: attribute 'linking'
« Reply #10 on: April 28, 2011, 03:13:26 PM »
i'm not trying to get the volume from a field. i'm trying to get the volume of an object to be dynamically linked to an attribute in a block.  i have a lisp routine that will allow me to select either a 3d object or masselement and then places a field in the drawing.  this is not that useful really when i can get that info by running massprop on the 3d solid or selecting the masselement and looking in the properties.  what i'm really after here is the ability to place the volume of an object into an attribute and have the attribute update if the objects volume changes.  now i can do this with a field in the attribute but again it's time consuming to edit and 'link' the object everytime.  so i'm trying to automate that process by being able to select the attribute and then select the object and be done.  i'm pretty sure that Lee Mac has this figured out with the area link that he posted in his response with some minor tweaking.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: attribute 'linking'
« Reply #11 on: April 28, 2011, 03:37:01 PM »
The code I linked to will allow you to link the volume property of a 3d solid, to a text entity ( attribute, text or mtext ).  You can use that, or wait for Lee to respond.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: attribute 'linking'
« Reply #12 on: April 28, 2011, 05:00:22 PM »
In my program change [Line 33]

Code: [Select]
(ssget '((0 . "ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE")))
to:

Code: [Select]
(ssget '((0 . "3DSOLID")))
And [Line 46]:

Code: [Select]
">%).Area>% + "
to:

Code: [Select]
">%).Volume>% + "

Oh, and change the command name and prompts accordingly.

rooster jk

  • Guest
Re: attribute 'linking'
« Reply #13 on: April 28, 2011, 05:24:36 PM »
that works for the 3dsolids...any ideas on how to make it work for both 3d solids and masselements?  also, back to the issue of it giving the data in cubic inches as opposed to cubic yards?  i'm really not sure what the answer will be here if we make it so that this will work on both 3d solids and masselements as they don't behave the same.  i have attached a lisp that i created from another lisp that i can't rememeber who wrote - so i appologize for not being able to tell who's this was to begin with...i'm posting it so you can see what i mean by it being able to do both 3dsolids as well as masselements and the difference in the data output.  to use this you have to first pick an object, then pick where you want the field to be placed, and then pick the object with the volume you want.  please let me know your thougths.

Code: [Select]
(defun c:VOL ()
(vl-load-com)
;;get a reference to model space
(setvar "textsize" 0.09375)
(setvar "luprec" 8)
(setq *model-space*
       (vla-get-ModelSpace
(vla-get-ActiveDocument (vlax-get-acad-object))
       )
)
;;pass this function an entity and a point
(defun Linkedvol (ent pt / obj objID ip width str)
  ;;convert the entity to an object
;;;  (setq obj   (vlax-ename->vla-object ent)
;;; ;;get the object ID
;;; objID (vla-get-objectid obj)

  (setq vl1 (car (entsel "\nSelect Volume Entity: ")))
  (setq objID (vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) "GetObjectIdString" (vlax-ename->vla-object vl1) :vlax-False))

  (setq ;;convert the point
ip    (vlax-3D-Point pt)
;;set the width for the MTEXT
width 0.0
  )
;;set the string - this creates the field
;;; str   (strcat
;;; "%<\\AcObjProp Object(%<\\_ObjId "(rtos objID 2 0)">%).Volume \\f \"%lu2%ct6%qcu yd\">%"
;;;      )

  (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Volume \\f \"%lu2%ct6%qf1%pr2 CU YD\">%"))

  ;;Create the MTEXT entity containing the field.
  (vla-addMText *model-space* ip width str)
)

;; Set A = the entity and set B = Point for text
(setq a (car (entsel)) b (getpoint "\n Select Point To Locate Field: "))
;;Call the function
(linkedvol a b)
(princ)
  )
« Last Edit: April 28, 2011, 08:03:49 PM by CAB »

rooster jk

  • Guest
Re: attribute 'linking'
« Reply #14 on: April 28, 2011, 05:29:05 PM »
it appears as though i need to get a lesson on how to post code!!!