leonucadomi Posted October 18 Posted October 18 hello: I'm trying to make a routine that selects a "VIEWPORT" then select a second "VIEWPORT" then the routine should move the first view to the place of the second, then delete the second The problem is that sometimes it doesn't move it to where it should and I don't know why. It's like it depends on the zoom here the code thanks (defun c:BM2 (/ e centro e2 centro2) (princ "\nBorra y Mueve VIEWPORTS") (terpri) (setq old_err *error*)(defun *error* ( a / )(princ "") (setq *error* old_err)(princ)) (setvar "cmdecho" 0) (setq e (car (entsel "\nSeleccione VIEWPORT 1: "))) (while (or (null e) ;nada seleccionado o invalida seleccion (not (eq (cdr (assoc 0 (entget e ))) "VIEWPORT"))) (setq e (car (entsel "\nNo es una entidad VIEWPORT. Selecciona otra vez: ")))) (terpri) (princ "VIEWPORT 1 seleccionada") (setq centro (cdr (assoc 10 (entget e)))) (setq e2 (car (entsel "\nSeleccione VIEWPORT 2: "))) (while (or (null e2) ;nada seleccionado o invalida seleccion (not (eq (cdr (assoc 0 (entget e2 ))) "VIEWPORT"))) (setq e2 (car (entsel "\nNo es una entidad VIEWPORT. Selecciona otra vez: ")))) (terpri) (princ "VIEWPORT 2 seleccionada") (setq centro2 (cdr (assoc 10 (entget e2)))) (command "_move" "_non" e "" centro centro2 "") (command "_erase" e2 "") (princ) );fin defun Quote
leonucadomi Posted October 18 Author Posted October 18 I found this one from teacher LEE It is similar to what I need (defun c:MacVP (/ ent1 ent2 Obj1 Obj2) (vl-load-com) (while (progn (setq ent1 (car (entsel "\nSelect Source Viewport: "))) (cond ((eq 'ENAME (type ent1)) (if (eq "VIEWPORT" (cdadr (entget ent1))) (while (progn (setq ent2 (car (entsel "\nSelect Second Viewport: "))) (cond ((eq 'ENAME (type ent2)) (if (not (eq "VIEWPORT" (cdadr (entget ent2)))) (princ "\n** Object is not a Viewport **"))) (t (princ "\n** No Viewport Selected **"))))) (princ "\n** Object is not a Viewport **"))) (t (princ "\n** No Viewport Selected **"))))) (vl-catch-all-apply (function (lambda ( ) (vlax-put-property (setq Obj2 (vlax-ename->vla-object ent2)) 'Center (vlax-3D-point (append (list (car (vlax-get (setq Obj1 (vlax-ename->vla-object ent1)) 'Center))) (cdr (vlax-get Obj2 'Center))))) (vla-put-width Obj2 (vla-get-Width Obj1))))) (princ)) Quote
BIGAL Posted October 18 Posted October 18 (edited) This was my test code and yes once I added osmode 0 it started to work. Just make the couple of changes to your code. Maybe experiment with the adding NON to your move with regards to the two points. (defun c:wow ( / oldsnap e1 e2 obj1 obj2) cen1 cen2) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq e1 (car (entsel "\nPick viewport 1 "))) (setq obj1 (vlax-ename->vla-object e1)) (setq cen1 (vlax-get obj1 'Center)) (setq e2 (car (entsel "\nPick viewport 2 "))) (setq obj2 (vlax-ename->vla-object e2)) (setq cen2 (vlax-get obj2 'Center)) (command "move" e1 "" cen1 cen2) (setvar 'osmode oldsnap) (princ) ) (c:wow) @leonucadomi beat me by 1 minute. Edited October 18 by BIGAL 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.