Jump to content

Recommended Posts

Posted

Attribute Object ID in Block.

 

Hi guys its me again, I am trying to create a tagging system linking the attribute to a text field, I have this routine from @Tharwat that creates a text+field after clicking on the target block w/ attribute (it does work with default ent. properties like Block Unit, Color, Layer, Name etc.) but my problem is the attribute def. it has a different ObjectId and since the routine that Tharwat create uses (car (entsel) it will only return the block ObjectId and not the Attribute ObjID inside.

Attribute ObjId 8796087888544

Others ObjId 8796087888528

 

Any Idea, is this feasible?

 

Tharwats routine

(vl-load-com)
(defun c:TAG (/ space ss pt)

(setq space (vla-get-modelspace
(vla-get-ActiveDocument (vlax-get-acad-object))
)
)
(if (and (setq ss (car (entsel "\n Select a BLOCK : ")))
(setq pt (getpoint "\n Specify TAG Location :"))
)
(vla-addMText
space
(vlax-3d-point pt)
4.
(strcat "%<\\AcObjProp Object(%<\\_ObjId "
(itoa (vla-get-ObjectID (vlax-ename->vla-object ss)))
">%).TextString \\f \"%tc1\">%"
)
)
(princ)
)
(princ)
)

:

ahahahaha.jpg

Posted

Hi,

 

Replace the function entsel with nentsel and pick on the attribute itself when you are asked to select a Block.

Posted

its working now with a big BUT :) , so the attribute need to be visible right?

 

thank you Tharwat

Posted
its working now with a big BUT :) , so the attribute need to be visible right?

 

thank you Tharwat

 

You are welcome.

 

Sure it supposed to be visible since the user input function asks you to pick an object that is available / seen on the screen.

Posted

If the attribute is not visible you can get at the attribute via its creation order but that would rely on you knowing what number when created.

 

Or use a "." for the attribute value its almost invisible, and then use Tharwat's method.

Posted
If the attribute is not visible you can get at the attribute via its creation order but that would rely on you knowing what number when created.

 

Or use a "." for the attribute value its almost invisible, and then use Tharwat's method.

 

any quicky snippets regarding to "If the attribute is not visible you can get at the attribute via its creation order but that would rely on you knowing what number when created. "

Posted

If you look at this then as it loops you get each attribute so you could change a attribute knowing how many times you need to go through the foreach use another if to change the attribute value and visibilty state.

 

(setq y (getint "attribute counter"))
(setq x 1)
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes)
(if (= x y)(vla-put-textstring att newstr1))
(setq x (+ x 1))
)

Posted

ok, consider this as solve. I found a workaround.

 

instead of using attribute I created a custom property for Equipments and Valves.

 

thank you again.

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...