Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Field Formulas

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Redraiderr2009
8001 Views, 5 Replies

Field Formulas

I am trying to put a field formula in an attribute value. Basically I have a block that has a attribute called QTY and it is equal to 1. I can get the object property to equal 1 with this expression:

 

%<\AcObjProp Object(%<\_ObjId #########>%).Textstring>%

 

The expression above will show a value equal to 1 (as I would expect)

 

Lets say I have two blocks now and I have the lisp routine combine the field values to get the expression below.

 

%<\AcObjProp Object(%<\_ObjId #########>%).Textstring>%+%<\AcObjProp Object(%<\_ObjId #########>%).Textstring>%

 

In the attribute dialog box it will show 1+1 instead of 2. My question is how do I get it to show 2 with out opening the formula box and evaluating it?

 

I have also tried.

%<\AcExpr(%<\AcObjProp Object(%<\_ObjId  #########>%).Textstring>%)+(%<\AcObjProp Object(%<\_ObjId  #########>%).Textstring>%)>%

and

%<\AcExpr((%<\AcObjProp Object(%<\_ObjId  #########>%).Textstring>%)+(%<\AcObjProp Object(%<\_ObjId  #########>%).Textstring>%))>%

 

 

5 REPLIES 5
Message 2 of 6
Lee_Mac
in reply to: Redraiderr2009

Use:

 

(vla-put-textstring <VLA Attribute Object>
    "%<\\AcExpr %<\\AcObjProp Object(%<\\_ObjId ##########>%).Textstring>% + %<\\AcObjProp Object(%<\\_ObjId ##########>%).Textstring>% >%"
)

 

Note the extra backslashes when used in a LISP expression.

Message 3 of 6
Redraiderr2009
in reply to: Lee_Mac

Did that with the formula but I think it is a different issue. I think it is looking for a field pointer or FldPtr which I do not know how to get. See attached image.

 

;;; this code is adding the string value of all the quantities in the block

 (setq NTB:QTY_FIELD (strcat "+" "(%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-objectid NTB:TREE_EA_NORMAL_ATT)) ">%).Textstring>%)" NTB:QTY_FIELD))

 

;;; this removes the plus sign from the beginning of the string

(setq NTB:QTY_FIELD (vl-string-left-trim "+" NTB:QTY_FIELD))

 

;;; this adds the string to include an expression for the formula.

(setq NTB:QTY_FIELD (strcat "%<\\AcExpr(" NTB:QTY_FIELD ")>%"))

 

Message 4 of 6
Lee_Mac
in reply to: Redraiderr2009

You are not following the example in my post - you don't need brackets outside of the property fields within the expression field.

 

Have a look at how I construct the field expression in this program.

Message 5 of 6
Redraiderr2009
in reply to: Lee_Mac

That did it. Thanks for the help.

 

In your opinion, is there a breakpiont for drawing performance and the number of fields that need to updated in a drawing. Have you run into that. I figure a typical drawing would have about a minimum of 500 and probably up to 2000 fields. Just wondering what your thoughts were.

Thanks,

Message 6 of 6
Lee_Mac
in reply to: Redraiderr2009

Not being a draftsman (just a programmer), I don't deal with many large drawings, but since fields are only updated on a regen, I would think they would only affect performance during regen, but regeneration is slow for any large drawing, so the difference may not be noticeable.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost