乐筑天下

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

[编程交流] Move form viewport's cent

[复制链接]

1

主题

9

帖子

8

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 14:14:16 | 显示全部楼层 |阅读模式
Hi guys, I'm new to the boards. I was wondering if you could help me. I have never used LISP's before and i think I'm in need to use one.
 
Here's my problem,
 
I have complied a series of commands in microsoft excel (to later copy to the command line in CAD) to quickly select and zoom to specific parts of my drawing, draw a viewport around it and import it to a specific layout tab. The problem i have is that my viewport is always in the bottom left hand corner of my layout page. Is there something I can do to select a viewport in Pspace and move it (from its center) to a specific coordinate on my layout, using only commands. i.e without any user input from the mouse.
 
it would be great if some one could help
 
many thanks
 
lee
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 14:20:44 | 显示全部楼层
Firstly, welcome to the forums Lee, I'm sure you'll like it here
 
I think you could use the vla-put-center method on the viewport object to move it to the correct position.
 
I am not sure what you have so far though, so can't really advise much more than that.
 
Lee
回复

使用道具 举报

1

主题

9

帖子

8

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 14:22:28 | 显示全部楼层
Hi, thanks for that,
 
As I said, I'm completely new to anything to do with LISP's. Is what you just gave me a command in CAD or something you would use in a LISP?
 
I think my previous post was a bit confusing.
 
I'll simplify it...
 
What I'm wanting to do is move a viewport (from its center) to a specific coordinate using only the keyboard, i.e commands that can be typed in. This is just so it looks neat went I send my drawings to clients.
 
thanks again
 
lee
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 14:24:10 | 显示全部楼层
 
Sorry, vla-put-center is a LISP method - I would approach this problem using LISP.
 
But, using the keyboard only, if you didn't want to stray into LISP, this may be difficult imo.
 
Lee
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 14:27:46 | 显示全部楼层
As an example code:
 
  1. (defun c:vpmove  (/ ent pt) (vl-load-com) (if (and (setq ent (car (entsel "\nSelect Viewport: ")))          (eq "VIEWPORT" (cdr (assoc 0 (entget ent))))          (setq pt (getpoint "\nSelect Point to move it to: ")))   (vla-put-center     (vlax-ename->vla-object ent)       (vlax-3D-point pt))) (princ))
回复

使用道具 举报

1

主题

9

帖子

8

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 14:32:29 | 显示全部楼层
thanks again,
 
I know I probably seem a bit stupid but I have never used LISP's.
 
I use CAD everyday at work and I understand most things but not lisp's.
 
how do I make a lisp? I know there is some sort of editor within CAD but i've never had to use it.
 
lee
回复

使用道具 举报

1

主题

9

帖子

8

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 14:35:24 | 显示全部楼层
i am wanting to select the viewport using move and then picking 10,10 (to select the viewport)

then i need to select where to move it from (need this to be its center)

then i need to place it at 165.6,133.5

this will leave it in the middle of my companies titleblock.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 14:38:55 | 显示全部楼层
 
Not a problem.
 
Firstly, do you know how to load and run a LISP?
 
If not, there is a tutorial here
 
If there is anything you don't understand about that, just ask.
 
As for the writing side:
 


  • I would suggest using the Visual LISP Editor provided in ACAD, open it by typing VLIDE at the command line. Then go to "File" > "New File" and you can begin writing your code.


  • If you have never written a LISP before, I would suggest starting with just plain AutoLISP and get competent in that, before maybe moving onto Visual LISP, as this is a bit more involved.


  • There are loads of tutorial sites you can visit, just Google: AfraLISP, JefferySanders, Ron Leigh.. etc etc

If you need any help on this code, I'd be more than happy to lend a hand.
 
Lee
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 14:39:44 | 显示全部楼层
 
This will put the center of the viewport at (165.6 133.5 0.0):
 
  1. (defun c:vpmove  (/ ent) (vl-load-com) (if (and (setq ent (car (entsel "\nSelect Viewport: ")))          (eq "VIEWPORT" (cdr (assoc 0 (entget ent)))))   (vla-put-center     (vlax-ename->vla-object ent)       (vlax-3D-point '(165.6 133.5 0.)))) (princ))
回复

使用道具 举报

1

主题

9

帖子

8

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 14:43:53 | 显示全部楼层
thank you very much!
 
so once the text is inserted into the lisp editor i then save it as a .lsp
and load it.
 
what do i then type to get the command to work?
 
will i need to select the viewport manually or can i do it using coordinates?
 
lee
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 03:06 , Processed in 0.772452 second(s), 72 queries .

© 2020-2025 乐筑天下

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