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

LISP and FIELDS

5 REPLIES 5
Reply
Message 1 of 6
timsparks6941
707 Views, 5 Replies

LISP and FIELDS

I'm successfully populating fields using LISP, but I have one issue...I need to make a negative field number positive.

 

What I am creating is a callout that has North, East coordinates and the elevation as three lines associated with a leader entity.

I place a point as the start of the leader and use Object settings of the point to get the XYZ to populate the coordinate fields.

 

I'm testing the coordinates to see if they are negative.  If negative then I specify a string that uses an 'S. ' or 'W. ' prefix in the field setting.

 

This works fine with one catch...the number remains negative, so I end up with something like S. -22477'-1 5/16" instead of S. 22477'-1 5/16".

 

I can use text instead of fields, but using fields, when a location changes I can regen and see the changes instead of erasing the callout and replacing it.

I'm really hoping there is an answer since I am this close...

 

Tim

Tags (2)
5 REPLIES 5
Message 2 of 6
Shneuph
in reply to: timsparks6941

Too bad there is no Absolute value function in Diesel (not in documentation anyway).

 

One work around is to maybe use the substr diesel function within your field to cut off the - (negative sign) in the front while testing if the value is negative.  A drawback is that if you move it and the number becomes positive it will then cut off the first digit.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 3 of 6
timsparks6941
in reply to: Shneuph

The issue is that the number is extracted from the axis coordinate of the object in the field below.

Is there a switch within this language that will make the number nuetral?

 

I don't know how you would pass a string to this after using substr.

 

  "(setq txt (strcat "%<\AcObjProp.16.2 Object(%<\_ObjId " id ">%).Coordinates \f \"%lu6%pt1%ps[S. ,]\">%"))"

 

%pt1 is the E value of the coordinate.

 

Message 4 of 6
Shneuph
in reply to: timsparks6941

I was thinking you could do something like the following examples:

%<$(substr,"hello",2)>%

or
%<$(*,-1,-2512.256)>%

 

This works to flip the numbers negative..

  %<$(*,-1,%<\AcObjProp Object(%<\_ObjId 8796088424688>%).Coordinates \f "%pt1">%)>%

 

But once the number is in the acobjprop value loses it's reference object and the number does not update anymore.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 5 of 6
timsparks6941
in reply to: Shneuph

"But once the number is in the acobjprop value loses it's reference object and the number does not update anymore." This solution defeats the purpose of using fields, although interesting.  Otherwise I would place text.

 

Thanks anyway for looking....

Message 6 of 6

Some other thoughts.

 

If you change the below line by adding an expression , the negative value will go away.

But now all the values are showing instead of X value.

I dont know how to avoid that.

 

(setq txt (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " id ">%).Coordinates \\f \"%lu6%pt1%ps[S. ,]\">%"))

 

try by changing the above line in your code with the below code.

 

(setq txt (strcat "%<\\AcExpr (" "%<\\AcObjProp.16.2 Object(%<\\_ObjId " id ">%).Coordinates \\f \"%lu6%pt1%ps[S. ,]\">%" " * -1)>%"))

 If you can consider dynamic block, please find the attached drawing.

Drawing contains a dynamic block with object field within it, so moving and regen will update the coord

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

Post to forums  

Autodesk Design & Make Report

”Boost