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

Diesel expression help (area)

14 REPLIES 14
Reply
Message 1 of 15
Anonymous
1157 Views, 14 Replies

Diesel expression help (area)

Can someone explain how I can update my diesel expression to display the area in square feet not square inches. See expression below. Thanks

^C^Cattdia;0;_-insert;AREABLK;\1;1;0;$M=$(getvar,AREA);attdia;1
14 REPLIES 14
Message 2 of 15
Kent1Cooper
in reply to: Anonymous

I'm not fluent enough in Diesel, but Lisp should work in a macro like that, too, something like this:

^C^Cattdia;0;_-insert;AREABLK;\1;1;0;(/ (getvar 'area) 144);attdia;1

or if it needs to be a text string:

^C^Cattdia;0;_-insert;AREABLK;\1;1;0;(rtos (/ (getvar 'area) 144) 2 2);attdia;1

Change that last 2 if you want more [or fewer] decimal places.

--
Kent Cooper


wilco4 wrote...
Can someone explain how I can update my diesel expression to display the area in square feet not square inches. ....

^C^Cattdia;0;_-insert;AREABLK;\1;1;0;$M=$(getvar,AREA);attdia;1
Kent Cooper, AIA
Message 3 of 15
Anonymous
in reply to: Anonymous

Thanks for the help but it's still not working right. Below are the results I get:

^C^Cattdia;0;_-insert;AREABLK;\1;1;0;(/ (getvar 'area) 144);attdia;1 gives me the follwoing: (/ (getvar 'area) 144)

^C^Cattdia;0;_-insert;AREABLK;\1;1;0;(rtos (/ (getvar 'area) 144) 2 2);attdia;1 gives me the follwoing: (rtos (/ (getvar 'area) 144) 2 2)


Here's what I get using my current expression on the same room:

^C^Cattdia;0;_-insert;AREABLK;\1;1;0;$M=$(getvar,AREA);attdia;1 gives me 57600


Any thoughts?
Message 4 of 15
Kent1Cooper
in reply to: Anonymous

Oops -- it's taking input for an Attribute value literally, rather than evaluating the Lisp expression. Try starting with this:

^C^Cattdia;0;texteval;1;_-insert....

and then end with

....attdia;1;texteval;0

I'm not sure why it should take a Lisp expression literally but not a Diesel expression, when TEXTEVAL is 0, but as I said, I'm not very experienced with Diesel. However, if the above doesn't work, someone who is more familiar with it should be able to do the same calculation [dividing your original expression by 144] in Diesel language.

--
Kent Cooper
Kent Cooper, AIA
Message 5 of 15
Anonymous
in reply to: Anonymous

Thanks again for trying but it's still not working. Below is my result using the latest expression:

(/ (getvar 'area) 144)
Message 6 of 15
Anonymous
in reply to: Anonymous

{code}^C^Cattdia;0;_-insert;AREABLK;\1;1;0;$M=$(rtos,$(getvar,AREA),4,3);attdia;1{code}
Message 7 of 15
Anonymous
in reply to: Anonymous

Getting closer. That expression divides the square inches by 12 and it actually needs to be divided by 144. Thanks...
Message 8 of 15
Anonymous
in reply to: Anonymous

Maybe this?
{code}^C^Cattdia;0;_-insert;AREABLK;\1;1;0;$M=$(rtos,$(/,$(getvar,AREA),144),2,3);attdia;1{code}
Message 9 of 15
Anonymous
in reply to: Anonymous

That worked. Thanks for the help. One last question. Is there a way to remove the decimal point and/or zeros. It shows up as 400.000 if not no big deal.
Message 10 of 15
Kent1Cooper
in reply to: Anonymous

Changing that 3 to a 0 [the precision argument in (rtos)] should do it.

--
Kent Cooper


wilco4 wrote...
.... Is there a way to remove the decimal point and/or zeros. ....
Kent Cooper, AIA
Message 11 of 15
Anonymous
in reply to: Anonymous

Works great! Maybe I'm being picky but can I add sq ft after the number? This is going to be quite a time saver for me.
Message 12 of 15
Anonymous
in reply to: Anonymous

^C^Cattdia;0;_-insert;AREABLK;\1;1;0;$M=$(rtos,$(/,$(getvar,AREA),144),2,0) "SQ FT";attdia;1
Message 13 of 15
Anonymous
in reply to: Anonymous

Perfect. Thanks again...
Message 14 of 15
Anonymous
in reply to: Anonymous

Hello, I'm a new member of the discussion groups, & have benefited from this thread.  I have recently started writing some macros in DIESEL, & have so far been reasonably succesful, however I have encountered a problem that has me baffled.

 

I have written a macro, which is very similar to that written by Wilco4 - It measures an area, inserts a block, & assigns the value of the measured area to a specific attribute within the block.

The intended purpose of the macro, is to assist me assign specific attributes to many rooms illustrated on a floor plan.

 

^C^C_MEASUREGEOM;AR:O;\^C^C_-insert;ROOM_LABEL;1;1;0 $M=$(getvar,ROOM_AREA);Room_AREA;1

 

 

This works well, however if I then run the macro a second time, then the initial block inserted adopts, & displays the new attribute value when autosave runs, or after the DWG is closed & reopened. 

Taking this to it's natural conclusion, if I were to run the macro 1oo times; I would end up with 100 blocks, which all display the last, (100th), measured value.

 

As well as the macro itself, I have also assigned the attribute default with a diesel expression to manage the data as "area".

 

What I would like to know: is there any way of "freezing" each attribute value immediately after assigning the same value, so that each block may hold independent attribute values?

 

Any help would be warmly received

 

B

Message 15 of 15
m_rogoff
in reply to: Anonymous

Hi, I am using this macro and it works great. I am wondering if there is anyway to build a field into this macro. This is desired because the field will automatically update as the area of the object changes.

 

%<\AcObjProp Object(%<\_ObjId 8795918873664>%).Area \f "%lu2">%

 

This is the expression for finding area with a field. The part highlighted red is the specific object chosen when in the field menu. Ideally, you can just enter LAST OBJECT instead of choosing the PLine itself.

 

Is there a way to write PLine in a macro so you can choose an unlimited number of points?

 

Thanks

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report