Lee Mac 发表于 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

Lee Mac 发表于 2022-7-6 14:49:35

Load it in the Editor using this button:
 

 
Then run it with the syntax that appears after : (defun c:

Lee5150 发表于 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

Lee Mac 发表于 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

Lee5150 发表于 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

Lee5150 发表于 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

Lee Mac 发表于 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

Lee5150 发表于 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.

Lee Mac 发表于 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

SteveK 发表于 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:

(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.
页: 1 [2]
查看完整版本: Move form viewport's cent