乐筑天下

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

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

[复制链接]

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 14:48:17 | 显示全部楼层
 
When the code is written in the Editor, you can load it straight from there, or save it as a .lsp and load it manually using "appload" at the command line.
 
In this case, type vpmove to activate the command - see the tutorial link I posted.
 
As for selecting the viewport, I can make a code that will let you select it using coords, but imo, it would be better to do the whole operation using LISP, instead of a mixture of commands from Excel. :wink:
 
Lee
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 14:49:35 | 显示全部楼层
Load it in the Editor using this button:
 
151420ekv0tktn5ab5lkl4.jpg
 
Then run it with the syntax that appears after : (defun c:
回复

使用道具 举报

1

主题

9

帖子

8

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 14:53:37 | 显示全部楼层
i work for a furniture manufacturing company called british thornton.
 
i know i have gone the long way around but what i need to do is have individual rooms on layout tabs. i have done this by drawing a rectangle around the room in mspace. then i give the rectangle a group name. i use a series of commands written in excel to select and copy the group, pull it through into layout 1 in pspace, then make it into a viewport then zoom and scale to the original group (therefore zooming to that room) i copy and paste it into the command line from and it does it in seconds. but because i used copyclip to copy the rectangle in the first place, and the pasting it at 0,0 on my layout, the viewport is not in the center.
 
i tried the lisp and once iv selected the viewport, it doesn't move.  
 
im sorry to mess you around
 
lee
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 14:57:24 | 显示全部楼层
Ok, I think that could all be done using LISP, but as you have got to this stage already, I think its best we carry on from here.
 
 
As for this, I tried the LISP on my machine, and the viewports is moved correctly. Is there any chance you could attach a sample drawing so that I could see whats wrong?
 
Lee
回复

使用道具 举报

1

主题

9

帖子

8

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 15:01:19 | 显示全部楼层
do you have an email address i could send the samples to because theyre too big to upload onto here?
 
thanks
 
lee
回复

使用道具 举报

1

主题

9

帖子

8

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 15:03:04 | 显示全部楼层
i figured out why the lisp didn't work. its because I'm using a viewport that is made from a polygon. i don't know if theres a way to do it with one of those.
 
lee
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:07:07 | 显示全部楼层
 
Ahh, yes that makes things slightly difficult.
 
I think you would have to find the centroid of the lwpolyline and then move it relative to that.
 
Lee
回复

使用道具 举报

1

主题

9

帖子

8

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 15:09:43 | 显示全部楼层
if you would like me to email you a sample of what i am trying to achieve i can do. maybe there is an easier way of doing it.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 15:13:50 | 显示全部楼层
I would send you my email address, but I can't seem to send you a PM with it
回复

使用道具 举报

14

主题

271

帖子

257

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 15:14:54 | 显示全部楼层
Hello,
 
I'm trying to do something similar with regards getting the center of the viewport:
I'm trying to modify the center of another viewport so that it has the same x co-ordinate as the other viewport. (And I'm also trying to do this is autolisp, not vlisp ).
I was looking at the viewport entity and I'm guessing the viewport's center is at dxf code 12, so based on that (and I know it's not the best code layout but) here's what I've got:
  1. (defun C:vp1 (/         en1 enlst1 en1_cen_x         en2 enlst2 en2_cen_x         new_cen) (setq en1 (car(entsel))   enlst1 (entget en1)) (setq en2 (car(entsel))   enlst2 (entget en2))  (Cond ((eq (cdr (assoc 0 enlst1)) "VIEWPORT")    (setq en1_cen_x (cadr (assoc 12 enlst1))))   ) (Cond ((eq (cdr (assoc 0 enlst2)) "VIEWPORT")    (setq en2_cen_x (cadr (assoc 12 enlst2))))   ) (If (AND en1_cen_x en2_cen_x)   (Progn     (setq new_cen (list en1_cen_x (caddr (assoc 12 enlst2)) (cadddr (assoc 12 enlst2))))     (entmod (subst (cons 12 new_cen) (assoc 12 enlst2) enlst2))     )(princ "Either or Both selections are not Viewports")   ) (entupd en2) (princ) )
This doesn't work. It just doesn't change the dxf code 12.
Does anyone know what the problem is?
 
EDIT: on further investigation it appears DXF code 17 is the modelspace centerpoint I'm after. But changing from 12 to 17 still doesn't replace the x co-ordinate in the second viewport. Any help would be great thanks.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

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

© 2020-2025 乐筑天下

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