LISP:Obtain Coordinates of a p
Could some help me with a LISP.Basically a LISP to
1) obtain the Coordinates of a user input point &
2) the zoom magnification of the same point and
3) save the values to an existing file & override it: ZoomToView.scr
This is the individual command I run to obtain the values for item 1 & 2
Command: IDSpecify point:X = 540.4345 Y = 166.2423 Z = 0.0000
Command: ZZOOMSpecify corner of window, enter a scale factor (nX or nXP), or : CSpecify center point:Enter magnification or height : *Cancel*Then transfer the values to an existing script file, save & override the existing file: ZoomToView.scr
This is what is inside ZoomToView.scr
ZoomC540.4345,166.2423,0.0000112.1034The location of the script where i save to is as follows:-
D:\Office\AutoCAD\Scripts\ZoomToView.scr
Thanks Use getpoint to obtain the point and query the VIEWSIZE system variable for the height.
Thanks Lee for the advise.
Alas, I do not understand LISP enough to write it out from scratch. Do appreciate if someone can help me out on this. This one is pretty simple so you should at least be able to give it a try with some guidance -The basic functions you will need are as follows:
defun
if
getpoint
getvar
open
progn
write-line
strcat
rtos
close
princ
I would first suggest reading the developer documentation for each of the above functions if you don't already know what they do.
The pseudo-code for the program (that is, the basic operations it needs to perform) would be something like:
define function if user gets point then if the target .scr file can be opened for writing then progn write-line "_.zoom" to file write-line "_C" to file write-line [strcat [rtos x-coord] [rtos y-coord] [rtos z-coord]] to file write-line [rtos [getvar viewsize]] to file close file else princ file could not be opened for writing princ Thanks Lee. Will give it a shot. Hope you can continue to guide me along the way.
For a start, any recommended link for the developer documentation I can read up on those functions you mention.
Thanks pretty simple HELP and find developers help which is say the same as this link http://docs.autodesk.com/ACDMAC/2013/ENU/PDFs/acdmac_2013_autolisp_reference_guide.pdf My suggestion is that there isn't really a need to create a script file. Instead, it would be easier to just create two separate lisp routines, one that stores the zoom information and one that zooms to the stored information. It is fairly easy using the commands Lee gave, you'll just need to make sure that your variables you store the zoom information in are global, not local.This way you won't have to mess with an extra file, but it will function the same way, it will just be quicker and more efficient. Let me know if you need any more help/suggestions because I'm glad to help. boncos15 I agree with Lee with no disrespect to Vernonlee he has 494 posts its about time to start learning rather than just take the freebies. Lots like me are here to help not just write code. BigAl, I agree, and I didn't know he had that many posts. By the way your posts have been really helpful to me for learning lisp.
Thanks BIGAL.
页:
[1]
2