View Full Version : How to text display an object's z coordinate?
VERYCIVILDRAFTER
14-02-2005, 04:54 PM
I want a block (attribute or rtext) to automatically update and display what elevation (Z coordinate) it's at.
I can't seem to figure out the code for this in rtext. :?
If it helps... my Land Development Desktop (LDD) lets me input multiple lines of code in rtext. This may verywell be true for basic AutoCAD, but LDD has a nice dialogue box for editing Diesels that I’ve never seen anywhere else.
Any help is appreciated.
VERYCIVILDRAFTER
14-02-2005, 06:25 PM
Maybe this will help?
I got this from autcad help...
$(index, which, string)
Assumes that the string argument contains one or more values delimited by the macro argument separator character, the comma. The which argument selects one of these values to be extracted, with the first item numbered 0. This function is most frequently used to extract X, Y, or Z coordinate values from point coordinates returned by $(getvar).
TCARPENTER
15-02-2005, 12:08 PM
Hi VCD,
Since no one has weighed in on this... I'm not a big rtext user but after looking at what you want to do, I think you'll want to take a closer look at the "eval" function in diesel. What you'll probably need to do is create a lisp routine to return the Z value of the block you just inserted, possibly using something like "entlast" to retrieve your Z information.
Sorry if that's no help
Todd
VERYCIVILDRAFTER
17-02-2005, 04:25 PM
Wow, this is harder than I thought...
What you'll probably need to do is create a lisp routine to return the Z value of the block you just inserted, possibly using something like "entlast" to retrieve your Z information.
Do you know how I would go about this in a lisp. Or could someone point me in the direction of a site that has a comprehensive list of lisp functions and syntax.
TCARPENTER
17-02-2005, 06:56 PM
Hi VCD,
I'm afraid it's been a little too long for me since I've done AutoLISP, but you may try www.cadshack.com, www.caddepot.com, www.afralisp.com just to name a few. The AutoCAD help files do have a comprehensive list of LISP functions and syntax that you'll need. The guys over at afralisp could probably help out. The cadshack and caddepot may have something you can just modify to your needs.
HTH
Todd
CarLB
17-02-2005, 09:15 PM
VCD,
The lisp routine to insert an attribute for elevation at block insertion is fairly simple. What would be more difficult would be to add the ability for the block to update the elevation if moved - which I believe is possible - but would take a "reactor" of some sort which I couldn't help with. The basic block insertion could be a macro, I think. First get insert point with "getpoint", extract the z valuestore the point. Something like:
(Setq Zval (caddr (setq Pt (getpoint "\nPick block insertion point: "))))
...then...
-insert;blockname;!Pt;...etc for scale & rotation...;!Zval;
this could be all done in a lisp routine, which you could assign to a button.
Hope this gives you some ideas......
VERYCIVILDRAFTER
17-02-2005, 11:52 PM
Just having a button that lists the z elevation would be good enough...
I'll admit I have next to no Lisp knowledge, but if I change your code to this=
(Setq Zval (caddr (setq Pt (getpoint "\nPick Object: "))))
Is this an “efficient” way to pick an objects elevation... or am I just grasping at straws? It seems to get the job done when I paste it into the command line.
You may yell NOOB!!1! if necessary.
So you can gauge my limited skills this is the most complicated DIESEL that I’ve ever written for an RTEXT... :) :? :( :cry:
SEE SHEET $(+,$(getvar,ctab),1)
CarLB
18-02-2005, 12:22 AM
Yes that code can be used to just give the z value of a selected point. Now if you want to get the zval of a selected object, that would be a little different. And to just get the zval it could be shortened to:
^P(caddr (getpoint "Pick Object: "))
I took out the backslash because that acts as a pause when in a macro. And the ^p is to suppress echoing the code to the command line.
We were all noobs once and still are, just in differnt fields....so keep plugging and asking :)
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.