Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Script to Place Point in Zoom Extents and Extract X,Y and/or Lat/Long

ODO18
Advocate

Script to Place Point in Zoom Extents and Extract X,Y and/or Lat/Long

ODO18
Advocate
Advocate

Trying to do some file data mining.  My idea is to extract into a txt file the dwg name and location along with the datum and x,y of a point and/or lat/long.  My script deletes and purges everything out of the dwg except our property line and then zooms to extent and then I execute the following point placement and data extraction.  I am trying to use the acconsolce for this so commands are limited that I can use.

 

I am stuck on finding a way to place point in middle of zoom extents and then getting the x,y of that point.  This is what I have for the calling of the data I need which includes file name, location, and file datum:

 

POINT ???? 

(setq ftkeepname (open "c:\\users\\xxx\\Documents\\Filename.txt" "w"))
(write-line (strcat (getvar "dwgprefix") (getvar "dwgname") (getvar "cgeocs") ftkeepname)
(close ftkeepname)

 

Any ideas?  Thank you

0 Me gusta
Responder
Soluciones aceptadas (3)
660 Vistas
7 Respuestas
Respuestas (7)

Kent1Cooper
Consultant
Consultant
Solución aceptada

@ODO18 wrote:

....

I am stuck on finding a way to place point in middle of zoom extents and then getting the x,y of that point.  ....


This will get the the middle of the screen following Zooming to the Extents, which you can use to draw a Point there if you need that, or just to gets the coordinates of that location if that's the purpose:

 

(getvar 'viewctr)

Kent Cooper, AIA

ODO18
Advocate
Advocate

Thank you very much. 

0 Me gusta

ODO18
Advocate
Advocate

Any thoughts on this? 

 

After getting it all together and having it working in Vanilla CAD, when I ran it through aeccoreconsole.exe with my script it did not work and I now I get this error in Vanilla CAD: ; "error: bad argument type: consp nil" when running the text below.  The script ran fine in the console to completion but never copied text into the notepad.

 

this is my script that copy's the text into the notepad:

(setq ftkeepname (open "c:\\users\\dodonohue\\Documents\\ScriptPro\\ArcGISFileData.txt" "w"))
(write-line (strcat (getvar "dwgprefix") ", " (getvar "dwgname") ", " (getvar "cgeocs") ", " (rtos (nth 0 viewctr)) ", " (rtos (nth 1 viewctr))) ftkeepname)
(close ftkeepname)

 

Also I was going to research this but if you know off the top of your head how to make the script not overwrite the text in the notepad, but instead to place the text in the next available blank line then that would be super appreciated.  But I also do not want to waste your time for something that may be out there already.

 

Thank you,

0 Me gusta

ODO18
Advocate
Advocate

Any thoughts on this? 

 

After getting it all together and having it working in Vanilla CAD, when I ran it through aeccoreconsole.exe with my script it did not work and I now I get this error in Vanilla CAD: ; "error: bad argument type: consp nil" when running the text below.  The script ran fine in the console to completion but never copied text into the notepad.

 

this is my script that copy's the text into the notepad:

(setq ftkeepname (open "c:\\users\\XXX\\Documents\\ArcGISFileData.txt" "w"))
(write-line (strcat (getvar "dwgprefix") ", " (getvar "dwgname") ", " (getvar "cgeocs") ", " (rtos (nth 0 viewctr)) ", " (rtos (nth 1 viewctr))) ftkeepname)
(close ftkeepname)

 

Also I was going to research this but if you know off the top of your head how to make the script not overwrite the text in the notepad, but instead to place the text in the next available blank line then that would be super appreciated.  But I also do not want to waste your time for something that may be out there already.

 

Thank you,

0 Me gusta

Kent1Cooper
Consultant
Consultant
Solución aceptada

@ODO18 wrote:

.... "error: bad argument type: consp nil" ....

....

(write-line (strcat (getvar "dwgprefix") ", " (getvar "dwgname") ", " (getvar "cgeocs") ", " (rtos (nth 0 viewctr)) ", " (rtos (nth 1 viewctr))) ftkeepname)
....


Start with this correction:
.... (rtos (nth 0 (getvar 'viewctr))) ", " (rtos (nth 1 (getvar 'viewctr)))) ....

Kent Cooper, AIA

Kent1Cooper
Consultant
Consultant
Solución aceptada

@ODO18 wrote:

....

(setq ftkeepname (open "c:\\users\\XXX\\Documents\\ArcGISFileData.txt" "w"))

....

... how to make the script not overwrite the text in the notepad, but instead to place the text in the next available blank line ....


Read about the options for the final argument in the (open) function:
....

(setq ftkeepname (open "c:\\users\\XXX\\Documents\\ArcGISFileData.txt" "a"))

....

Kent Cooper, AIA

ODO18
Advocate
Advocate

Ignore that if you saw it.  Glanced too fast and missed the getvar with extra ().  That worked!!! thank you!

0 Me gusta