iconeo Posted June 14, 2016 Posted June 14, 2016 I'm looking a lisp that can run from modelspace that will move object(s) from modelspace to paperspace. I'm assuming that there is only one paperspace window. Anyone see anything like this? Thanks. Quote
Tharwat Posted June 14, 2016 Posted June 14, 2016 Simple and quickie one: (defun c:test (/ ss i lst lay doc) ;; Tharwat 15.June.2016 ;; (if (not (eq (getvar 'ctab) "Model")) (princ "\n ** Command not allowed in Paper Space **") (if (setq ss (ssget "_:L")) (progn (repeat (setq i (sslength ss)) (setq lst (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) lst)) ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) lay (vla-item (vla-get-layouts doc) (car (layoutlist))) ) (vlax-invoke doc 'copyobjects lst (vla-get-block lay)) (mapcar 'vla-delete lst) ) ) ) (princ) )(vl-load-com) Quote
iconeo Posted June 14, 2016 Author Posted June 14, 2016 Awesome and almost! The object just needs to be scaled according to the paperspace scale which I can figure out. Don't know how you guys keep all that knowledge in your head all the time. Quote
iconeo Posted June 14, 2016 Author Posted June 14, 2016 Hmm, a bit trickier for me than I thought. It needs to scale from 0,0 at the paperspace scale. So I don't know how to access that scale while in modelspace... Quote
Tharwat Posted June 14, 2016 Posted June 14, 2016 Don't know how you guys keep all that knowledge in your head all the time. Become a habit. The object just needs to be scaled according to the paperspace scale which I can figure out. What is the scale factor that you would like to scale the objects when they moved to paper space? Quote
iconeo Posted June 14, 2016 Author Posted June 14, 2016 Dangit. I just remembered that I can use the dimscale...below didn't work for me. (defun c:test (/ ss i lst lay doc int) ;; Tharwat 15.June.2016 ;; (if (not (eq (getvar 'ctab) "Model")) (princ "\n ** Command not allowed in Paper Space **") (if (setq ss (ssget "_:L")) (progn (repeat (setq i (sslength ss)) (setq lst (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) lst)) ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) lay (vla-item (vla-get-layouts doc) (car (layoutlist))) ) (vlax-invoke doc 'copyobjects lst (vla-get-block lay)) (setq int (1 / (getvar "dimscale"))) (command "scale" (entlast) "0,0" int) (mapcar 'vla-delete lst) ) ) ) (princ) )(vl-load-com) Quote
iconeo Posted June 14, 2016 Author Posted June 14, 2016 Modelspace to Paperspace Thanks for chiming in Lee. I saw your LISP but I needed it to be able to run it without having to work through a viewport. Thanks. Quote
Tharwat Posted June 14, 2016 Posted June 14, 2016 Try this: (defun c:test (/ ss i lst lay doc objs int) ;; Tharwat 15.June.2016 ;; (if (not (eq (getvar 'ctab) "Model")) (princ "\n ** Command not allowed in Paper Space **") (if (and (setq ss (ssget "_:L")) (progn (repeat (setq i (sslength ss)) (setq lst (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) lst)) ) lst ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) lay (vla-item (vla-get-layouts doc) (car (layoutlist))) ) (apply 'and (setq objs (vlax-invoke doc 'copyobjects lst (vla-get-block lay)))) (setq int (/ 1. (getvar "dimscale"))) ) (progn (mapcar '(lambda (u) (vla-scaleentity u (vlax-3d-point '(0. 0. 0.)) int)) objs) (mapcar 'vla-delete lst) ) ) ) (princ) )(vl-load-com) Quote
iconeo Posted June 14, 2016 Author Posted June 14, 2016 Ah yes, thank you much. Now I can force those revclouds out of my modelspace... For my ignorance, is it not possible to use entlast because of VLA? Quote
Tharwat Posted June 14, 2016 Posted June 14, 2016 You are welcome and good luck with your work. Quote
Roy_043 Posted June 15, 2016 Posted June 15, 2016 @ Tharwat: why do you have this in your code?: (apply 'and (setq objs ... )) Quote
Tharwat Posted June 15, 2016 Posted June 15, 2016 @ Tharwat:why do you have this in your code?: (apply 'and (setq objs ... )) Because list of objects would always return T even if the elements of the list is a list of nil and in my previous codes I added the apply with and to get sure that all elements in the list is valid and equal to true then to continue to next line. eg: _$ (and '(nil nil nil)) T _$ (and '(t nil nil)) T _$ (apply 'and '(t nil nil)) nil _$ (apply 'and '(t t t)) T Quote
Roy_043 Posted June 15, 2016 Posted June 15, 2016 @ Tharwat: I understand that. But I can't think of a case where (vlax-invoke doc 'copyobjects ...) returns a list with a nil. Quote
Tharwat Posted June 15, 2016 Posted June 15, 2016 Agreed and it is just another way of writing the program, nothing's more. 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.