Jump to content

Recommended Posts

Posted

Hi, i'm attempting to create a function (for BricsCAD) which allows a user to select a block & then select a point of insertion for a field object which references a value in the selected block.

Figuring that my first step would be to get the value from the block, (with Lee Mac's attribute functions) i was able to extract the sheet number attribute & simply print it.

(defun c:s2f (/ blk val)
  (setq blk (vlax-ename->vla-object (car (entsel "\nSelect block: "))))
  (setq val (LM:vl-getattributevalue blockEnt "SHEETNUM"))
  (print "\nSheet number: " val "")
)

(defun LM:vl-getattributevalue ( blk tag )
    (setq tag (strcase tag))
    (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes))
)

Next, i tried to learn how to create a field. i attempted to modify Lee Mac's quickfield function, but it returns "...does not have SHEETNUM property."
Reading through this topic and this topic has also been quite difficult for me.

i can see that we have to pull the object id & also append the property to the same string to actually reference the field to the block's attribute, but i'm struggling to identify where/how the field command is called (if at all) and how the inputs are processed.

Is it just a text command using the specified "<\\AcObjProp Object(%<\\_ObjId xxxxxx >%).yyyyyy \\f \"zzzzzz">%" in the contents that creates a field?

Are these expressions different to each other? They all seem to be intended to achieve the same thing (returning the ObjId for the above string).

(vla-getobjectidstring (vla-get-utility (vla-get-activedocument (vlax-get-acad-object))) (vlax-ename->vla-object ent) :vlax-false)

(vla-get-objectid (vlax-ename->vla-object ent))
 

(vlax-get obj 'ObjectID)
 

(vla-get-objectid entObject)

(vlax-invoke-method util "GetObjectIdString" o :vlax-False)

Posted

If you use Lee Macs function or just Field command this will give you the text string to use for a field - and that can be pasted as text into the drawing.

 

For example, this:

%<\AcSm Sheet.Number \f "%tc4">%

will create a the current sheet number

 

You can put text around this if you like such as:

Sheet: %<\AcSm Sheet.Number \f "%tc4">%

 

 

 

For the VLA- functions, it often depends how you selected the object or entity which to use

  • Like 1

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