乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 17|回复: 17

[编程交流] LISP:Obtain Coordinates of a p

[复制链接]

48

主题

304

帖子

256

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
240
发表于 2022-7-5 18:23:31 | 显示全部楼层 |阅读模式
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
  1. Command: [b]ID[/b]Specify point:  X = [color=red][b]540.4345[/b][/color]     Y = [b][color=red]166.2423[/color][/b]     Z = [b][color=red]0.0000[/color][/b]
  1. Command: [b]Z[/b]ZOOMSpecify corner of window, enter a scale factor (nX or nXP), or[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] : 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
  1. ZoomC[color=red][b]540.4345[/b][/color],[b][color=red]166.2423[/color][/b],[b][color=red]0.0000[/color][/b][color=blue][b]112.1034[/b][/color]
The location of the script where i save to is as follows:-
D:\Office\AutoCAD\Scripts\ZoomToView.scr
 
Thanks
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:29:23 | 显示全部楼层
Use getpoint to obtain the point and query the VIEWSIZE system variable for the height.
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
240
发表于 2022-7-5 18:31:18 | 显示全部楼层
 
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.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:36:40 | 显示全部楼层
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:
  1. [color=blue]def[/color]i[color=blue]n[/color]e function        [color=blue]if[/color] user [color=blue]get[/color]s [color=blue]point     [/color]   then                [color=blue]if [/color]the target .scr file can be [color=blue]open[/color]ed for [color=darkred]w[/color]riting                then           [color=blue]progn[/color]           [color=blue]write-line[/color] [color=darkred]"_.zoom"[/color] to file           [color=blue]write-line[/color][color=darkred] "_C"[/color] to file           [color=blue]write-line[/color] [[color=blue]strcat [/color][[color=blue]rtos [/color]x-coord] [[color=blue]rtos [/color]y-coord] [[color=blue]rtos [/color]z-coord]] to file           [color=blue]write-line[/color] [[color=blue]rtos [/color][[color=blue]getvar [/color][color=darkred]viewsize[/color]]] to file           [color=blue]close [/color]file             else                        [color=blue]princ [/color]file could not be opened for writing [color=blue]princ[/color]
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
240
发表于 2022-7-5 18:38:40 | 显示全部楼层
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
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:44:19 | 显示全部楼层
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
回复

使用道具 举报

95

主题

477

帖子

383

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
475
发表于 2022-7-5 18:45:00 | 显示全部楼层
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.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:50:44 | 显示全部楼层
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.
回复

使用道具 举报

95

主题

477

帖子

383

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
475
发表于 2022-7-5 18:53:07 | 显示全部楼层
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.
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
240
发表于 2022-7-5 18:56:27 | 显示全部楼层
 
Thanks BIGAL.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-12 19:34 , Processed in 0.518440 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表