Nested fields

A colleague of mine is working as a freelancer for an office which uses AutoCAD, and quite naturally, they want him to adhere to their drafting standards.
Generally, this is not really a problem with BricsCAD, but there is one fly in the ointment:

They use blocks with attributes that contain formula fields as architectural ordinate dimensions, and these attributes always display '0.000' in BricsCAD, instead of the y-distance between a reference block and the attributed block, as it seems to be in ACAD (see attached drawing).

The formula in the attribute looks like this:
%<\AcExpr (dist(%<_FldIdx 0>%,%<_FldIdx 1>%)*sin(ang(%<_FldIdx 2>%,%<_FldIdx 3>%)-%<_FldIdx 4>%)) \f "%lu2%pr3%ct8[0.001]">%

It seems that the %<_FldIdx *>% expressions are nested fields that retrieve the coordinates of the respective blocks, but I cannot find a way to edit these.

Am I right to assume that nested fields are not currently supported in BricsCAD, or am I simply overlooking something?

Comments

  • Jason Bourhill
    edited June 2020

    It is possible, but it is limited and not that straightforward to do. It's limited because not all formulae are supported. It would seem that the formulae "dist", "sin", "ang" aren't supported yet, hence BricsCAD doesn't display a result. However, simple operators like + , - , * are supported. In your case it is possible to re-work the formula to get the desired result by subtracting the Y value of the origin block from the Y value of the target block.

    To build the formulae it is easier to break it down into its parts.

    Step 1 - Origin_Y
    Create a FIELD that gives you the Y coord of the Origin block.

    %<\AcObjProp Object(%<\_ObjId 855456944>%).InsertionPoint \f "%lu2%pr3%pt2">%
    

    Step 2 - Target_Y
    Create a FIELD that gives you the Y coord of the target block.

    %<\AcObjProp Object(%<\_ObjId 855456944>%).InsertionPoint \f "%lu2%pr3%pt2">%
    

    Step 3 - Formula of Target_Y-Origin_Y
    This is the tricker bit. We now must create a formula that subtracts the Origin Y coord from the Target Y coord. I've shown this using a formula field, but it could be easier to create in a text editor.

    The formula structure is

    %<\AcExpr ( Target_Y - Origin_Y) \f "%lu2%pr3%ct8[0.001]">%
    

    Where Target_Y & Origin_Y are replaced for the formula we created in steps 1 & 2. In full it looks like

    %<\AcExpr (%<\AcObjProp Object(%<\_ObjId 1925136928>%).InsertionPoint \f "%lu2%pt2%pr3">%-%<\AcObjProp Object(%<\_ObjId 855456944>%).InsertionPoint \f "%lu2%pt2%pr3">%) \f "%lu2%pr3%ct8[0.001]">%
    

    Step 4 - Paste Formula
    The last step is to copy & paste the formula string into the attribute value of our target block.

    Now the formula is in our block, you can COPY it to where ever it's needed.

    The attached drawing gives an example of this, and the text file is a copy of the steps above in case this forum strips the formatting.

    It should be possible to build some LISP around this. I know Lee Mac has several examples of working with fields on his site, such as Quickfield.

    You can find the Object ID of entities using LISP

    (vla-get-ObjectID (vlax-ename->vla-object (car (entsel "\nSelect entity: "))))
    

    Regards,
    Jason Bourhill
    BricsCAD V20 Ultimate
    CAD Concepts

  • Great, thanks so much - this is more than I expected!

    This should represent a viable workaround for my colleague - the only caveat that I see is that the original formula might also work for blocks that have been rotated, so maybe opening a SR still makes sense (I guess implementing the missing bits should not be too hard for Bricsys).

    What still puzzles me is that your field expression displays as %<\AcExpr (%<_FldIdx 0>%-%<_FldIdx 1>%) \f "%lu2%pr3%ct8[0.001]">% in the field dialog, so the underlying formulae remain inaccessible - do you know if this is by design, or a current limitation?

    For my own use, I so far created specially crafted linear dimensions with attached reactors for level dimensioning, but this solution looks inherently simpler, makes me consider switching my habits....

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Click one of the buttons on the top bar to get involved!