Community
AutoCAD LT Forum
Welcome to Autodesk’s AutoCAD LT Forums. Share your knowledge, ask questions, and explore popular AutoCAD LT topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Retrieving X and Y Coordinates (Ordinate Dimensions)

12 REPLIES 12
Reply
Message 1 of 13
Anonymous
1049 Views, 12 Replies

Retrieving X and Y Coordinates (Ordinate Dimensions)

I can get the X-coordinate to show up using Ordinate Dimension or I can get
the Y-coordinate to show up using the same command. However, I can't get
the X- and Y-coordinates to show up TOGETHER.

Please tell me if there is a way to get them to show up without me having to
use the Locate Point tool and then copying and pasting the X, Y results from
the command line to Multiline Text Editor when I want it to get X,Y
coordinates it to show up on my map.

Any Help would be graciously welcomed,

Nathan
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

Use the following in a toolbar button (remove the +), make sure your Qleader
is setup as you wish it to be first:

^C^C_id;\_setenv;pickpoint;$M=$(getvar,lastpoint);+
_leader;@;\;$M="$(getenv,pickpoint)";;^M;

--
Dean Saadallah
Add-on products for LT
http://www.pendean.com/lt
--
Message 3 of 13
Anonymous
in reply to: Anonymous

Works well. Just a quick question Dean, how do I set the number of decimal places in the output from this macro? I've tried setting it in the dimension style and in Units but stil get 8 places.

Bob
Message 4 of 13
Anonymous
in reply to: Anonymous

I can't get this to work.
Using LT2007 - is that why?
Why is the + sign there if it's not needed?
Message 5 of 13
Anonymous
in reply to: Anonymous

It nearly works but cancels before it completes.
Note values are to 8 decimal places although units set to 0.
Text window reads thus:

Command: _id
Specify point: X = 9974743 Y = 20030544 Z = 24511

Command: _setenv
Enter variable name: pickpoint
Value <9972248.75668649,20035227.07396786,24510.799>:
9974743.39965623,20030544.13093419,24510.799

Command: _leader

Specify leader start point: @

Specify next point:
Message 6 of 13
Anonymous
in reply to: Anonymous

Dean - any ideas re: this?
It would be nice if it works.
Thanks.
Message 7 of 13
Anonymous
in reply to: Anonymous

Try removing the space between "_leader;@;" and "\;$M="$(getenv,pickpoint)";;^M;".
It's generating an unneeded Enter.

Also, for long lines of code, the plus sign at the end indicates the code is to be all on one line but is broken to the next line for ease in reading.
The AutoCAD menu language supports this.
Whether "+" is there or not is forcode readability only, nothing to do with execution.
Message 8 of 13
Anonymous
in reply to: Anonymous

Thanks Kevin - that works.
Only fault is it gives the value to 8 decimal places even though the units are set to 0 and dim precision set to 0.
Any ideas?
Message 9 of 13
Anonymous
in reply to: Anonymous

I'm glad I could help with the macro code.
But I don't understand your original post.
Perhaps you could upload the DWG so I may better understand (and possibly help) with your situation.
Message 10 of 13
Anonymous
in reply to: Anonymous

Only fault is it gives the value to 8 decimal places even though the units are set to 0 and dim precision set to 0.

This bit?

Thanks again - file attached.
Message 11 of 13
Anonymous
in reply to: Anonymous

Hello,

As you've discovered, it looks like LT ignores decimal precision from styles when writing the coordinates from ID to environment variables (which are written to and read from the Windows Registry).
All is not lost, though.

I've written a VBScript file which reads your style's precision (DIMDEC) and the custom environment variable "pickpoint".
This VBScript file rounds the coordinates to your DIMDEC precision and overwrites the new data back into the Registry.

This doesn't work for Architectural units.

You'll need several items to do this:
1) The VBScript code (include below) IT has comments to help explain.
2) Windows Script Host (WSH) which you get from Microsoft (ver. 5.7)
3) The correct Registry paths to custom LT environment variables (sse below).
4) New LT macro code (included below).
5) Add a "Batching" folder to your list of LT support paths.

#1: Copy and save this text in a text file named "TrimLastpointPrecision.vbs" (it must have a vbs extension):
'TrimLastpointPrecision.vbs
'Kevin P. Chandler 2008
'Reads the Windows Registry for custom AutoCAD environment variables to
'set a saved coordinate set to a specific decimal precision.
Set objShell = WScript.CreateObject("WScript.Shell")
'Read decimal precision environment variable from the Registry.
strDIMDECPRECISION = objShell.RegRead _
("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD LT\R13\ACADLT-6001:409\FixedProfile\General\DIMDECPRECISION")
'Convert the precision to an integer.
intDIMDECPRECISION = CInt(strDIMDECPRECISION)
'Read pickpoint environment variable from the Registry.
Set objShell = WScript.CreateObject("WScript.Shell")
strPickpoint = objShell.RegRead _
("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD LT\R13\ACADLT-6001:409\FixedProfile\General\pickpoint")
'Strip the XYZ coordinates into an array of coordinates.
arrCoordinates = Split(strPickpoint, ",")
'Convert each coordinate into an integer to remove all decimal places.
for i = LBound(arrCoordinates) to UBound(arrCoordinates)
'Format each coordinate to AutoCAD's DIMDEC variable.
arrCoordinates(i) = FormatNumber(CDbl(arrCoordinates(i)), intDIMDECPRECISION)
next
'Rebuild the pickpoint.
strPickpoint = CStr(arrCoordinates(0)) & ", " & CStr(arrCoordinates(1))
'The line above concatenates X and Y, but not Z.
'Delete the apostrophe from the beginning of the next line to include Z in the new pickpoint.
'strPickpoint = strPickpoint & ", " & arrCoordinates(2)
'Write the rebuilt pickpoint environment variable back to the Registry.
'This overwrites the original pickpoint variable.
'If you want to keep the original values, then change "pickpoint" in the RegWrite command below
'to some other value, like "pickpoint2".
'If you do change pickpoint to a new name, adjust your menu code accordingly.
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.RegWrite _
"HKEY_CURRENT_USER\Software\Autodesk\AutoCAD LT\R13\ACADLT-6001:409\FixedProfile\General\pickpoint", _
strPickpoint, "REG_SZ"
'Reread the Registry to force the update in time for AutoCAD to use in the remainder of the macro.
Set objShell = WScript.CreateObject("WScript.Shell")
strPickpoint = objShell.RegRead _
("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD LT\R13\ACADLT-6001:409\FixedProfile\General\pickpoint")
'End TrimLastpointPrecision.vbs

#2: WSH is need to run vbs scripts.
In a Windows Run dialog, type cmd to open a command window. In the cmd window, type cscript and Enter.
If Windows says huh?, you need to get WSH from billg.

#3: Custom LT environment variables, such as "pickpoint" are stored in the Windows Registry.
They're stored in an AutoCAD version-specific location, which may not match the paths in the VBS code above (mine).
In LT, use SETENV to create a custom var.
Use "pickpoint" for the var's name and something odd/unique for its value, like ZQZQZQZQ. (Something easily searched for.)
In a Windows Run window, type REGEDIT.
WARNING: There's no UNDO in the Registry Editor and there's no Save because ALL CHANGES ARE IMMEDIATE, whether they're good or bad. So be careful.
You've been warned.
Search for the value you entered in LT, like my ZQZQZQZQ.
When it's found, review the path in the status bar at the bottom of REGEDIT.
(HKEY_CURRENT_USER may be abbreviated as HKCU)
If it's different than the code, edit the code (in all places) to your Registry path.
Save the VB code.
Close REGEDIT.

#4) You'll need this new LT menu code (one line):
^C^C_setenv;DIMDECPRECISION;$M=$(getvar,DIMDEC);_id;\_setenv;pickpoint;$M=$(getvar,lastpoint);_ai_startapp;"TrimLastpointPrecision.vbs";delay 1500;_leader;@;\;$M="$(getenv,pickpoint)";;^M;

When the vbs code is run, a command window opens briefly and closes automatically.
The DELAY (currently 1.5 seconds) is there to allow the vbs code to do its thing before LT continues.
Don't shorten this DELAY too much or the whole thing doesn't work.

#5: (Optional) I recommend you create a "Batching" folder and add it to your list of LT support paths (OPTIONS).
If you're networked, create it on a mapped drive, like:
Z:\AutoCAD LT Support\Batching
If you don't save the VBScript file where LT can find it, you'll need to add the vbs path to your menu code.
This is a maintenance pain. Add one entry to your list under "Support File Search Path" and your done.

While you're at it, do one for your LT scripts, too:
Z:\AutoCAD LT Support\Scripts
Now LT scripts (scr) can be run from menu code w/o paths.
Leave spaces out of the scr file names and you don't need to quote them.

I've tested this on my LT and it works.
I hope it works for you, too.
Message 12 of 13
Anonymous
in reply to: Anonymous

Goodness me Kevin - you like a challenge.
Thankyou very much - I will try this one day.
Bit worried about screwing up the registry (it's happened to me before).

Cheers.........
Message 13 of 13
Anonymous
in reply to: Anonymous

I'm glad to help.

It's good to be cautious around the Registry.
But remember, SETENV writes to it, too.
You only need to use REGEDIT once and only to verify your path to the variables SETENV creates is the same as mine.

Open REGEDIT. Press Ctrl+F and enter the search string "ZQZQZ" (or whatever you used).
REGEDIT will take you to the entry.
Read the path at the bottom of the REGEDIT screen.
If they differ, make note of your path (separately from REGEDIT).
Close REGEDIT.
Edit the VB code accordingly. All of the Registry paths in the VB code as the same. The environment variable names are at the end of the path.

The VB code reads and writes to the Registry, but only to the same entries SETENV and GETENV in LT use.
It doesn't go elsewhere in the Registry.

Good luck and take care.

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

Post to forums  

Autodesk Design & Make Report

”Boost