ziele_o2k Posted July 24, 2017 Share Posted July 24, 2017 I have a dwg file exported from program. This program exports everything to paperspace. I whant to move everything to model space. I think that chspace command won't work because there is no viewports in layouts. Every dwg file has only one layout. After moving objects to model space i would like also to scale them Quote Link to comment Share on other sites More sharing options...
maratovich Posted July 24, 2017 Share Posted July 24, 2017 Comand line: _exportlayout Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 24, 2017 Share Posted July 24, 2017 For same dwg draw a viewport around the objects but set the correct scale for it then use CHSPACE. This will scale also. Quote Link to comment Share on other sites More sharing options...
ziele_o2k Posted July 24, 2017 Author Share Posted July 24, 2017 Please move this topic back to AutoLISP, Visual LISP & DCL because I want to achieve this using lisp. Anyway, I will try with BIGAL proposition. Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 24, 2017 Share Posted July 24, 2017 Will the scale factor be fixed or variable? Quote Link to comment Share on other sites More sharing options...
maratovich Posted July 24, 2017 Share Posted July 24, 2017 The following request will be: Make a different scale Images to put near To encircle the image Do this for 100500 files at a time Collect all of the different files in one file ... So ? Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 24, 2017 Share Posted July 24, 2017 And that's how a quick little routine balloons into a full fledged program. It's called "project creep". LOL Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 24, 2017 Share Posted July 24, 2017 ziele_o2k a sample dwg goes a long way to solving your problem after the 1st post. Quote Link to comment Share on other sites More sharing options...
ziele_o2k Posted July 25, 2017 Author Share Posted July 25, 2017 Once again. For steel detailing, I'm useing AdvanceSteel. This program make documentation in separate dwgs in paper space (one drawing - one dwg, model space is empty). All i whant to get, is open dwg, copy or move all objects from paper space to model space, scale objects in model space (scale factor is saved in attribute from drawing table), save file and exit. To open multiple drawings I will use LeeMac script writer. _exportlayout will not work, because this exports layout to new dwg. First sample: (defun m2ms ( / ps ss pts vp ) (setq ps (car (layoutlist))) (setvar 'CTAB ps) (if (setq ss (ssget "_X" (list (cons 410 ps)))) (progn (setq pts (LM:ssboundingbox ss)) (setq vp (cd:ACX_AddViewport (cd:ACX_Paper) (car pts) (-(caadr pts) (caar pts)) (-(cadadr pts) (cadar pts)) 1 3)) (vla-put-CustomScale vp 0.1) ; to change (vl-cmdf "_.chspace" ss "") ) ) (princ) ) Subfunctions: (defun LM:ssboundingbox ( sel / idx llp ls1 ls2 obj urp ) (repeat (setq idx (sslength sel)) (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))) (if (and (vlax-method-applicable-p obj 'getboundingbox) (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp)))) ) (setq ls1 (cons (vlax-safearray->list llp) ls1) ls2 (cons (vlax-safearray->list urp) ls2) ) ) ) (if (and ls1 ls2) (mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list ls1 ls2)) ) ) (defun cd:ACX_AddViewport (Space Pb Width Height HJust VJust / obj) (setq Pb (trans Pb 1 0)) (cond ( (= HJust 1) (setq Pb (list (+ (car Pb) (/ Width 2)) (cadr Pb) (caddr Pb))) ) ( (= HJust 3) (setq Pb (list (- (car Pb) (/ Width 2)) (cadr Pb) (caddr Pb))) ) ) (cond ( (= VJust 1) (setq Pb (list (car Pb) (- (cadr Pb) (/ Height 2)) (caddr Pb))) ) ( (= VJust 3) (setq Pb (list (car Pb) (+ (cadr Pb) (/ Height 2)) (caddr Pb))) ) ) (vla-Display (setq obj (vla-AddPViewport Space (vlax-3d-point Pb) Width Height ) ) :vlax-true ) obj ) (defun cd:ACX_Paper () (setq *cd-PaperSpace* (vla-get-PaperSpace (cd:ACX_ADoc))) ) (defun cd:ACX_ADoc () (or *cd-ActiveDocument* (setq *cd-ActiveDocument* (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) *cd-ActiveDocument* ) Quote Link to comment Share on other sites More sharing options...
maratovich Posted July 25, 2017 Share Posted July 25, 2017 And? What is the problem ? Give the sample file. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 26, 2017 Share Posted July 26, 2017 Just use the CopyObjects and ScaleEntity methods. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 26, 2017 Share Posted July 26, 2017 I am starting to think more like Roy_043 just use copy and paste and re-scale. Paste each layout next to the last with a gap. Maratovich may be on the money also create a new dwg and just insert into a master dwg. I do not use advance steel but it would seem odd to not have a make a single file with multiple layouts for a project have you checked that also. Quote Link to comment Share on other sites More sharing options...
maratovich Posted July 26, 2017 Share Posted July 26, 2017 I can do this on the VBA. Or make an .exe program Processing without opening files. But I need to know everything. For example, what scale? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 26, 2017 Share Posted July 26, 2017 Hi, Try this program and let me know how you get on with it. (defun c:test (/ doc scl sel int pnt ent lst mvs) ;;------------------------------------;; ;; Tharwat - Date: 26.07.2017 ;; ;; Move objects from Paper Space to ;; ;; Model Space and scale them as per ;; ;; the scale factor specified from ;; ;; the user. ;; ;;------------------------------------;; (if (and (or (/= (getvar 'ctab) "Model") (alert "Command is not allowed in Model Space <!>") ) (setq scl (getdist "\nSpecify the scale factor :")) (princ "\nSelect objects to move to Model space then to scale :") (setq doc (vla-get-activedocument (vlax-get-acad-object)) int -1 pnt (vlax-3d-point '(0. 0. 0.)) sel (ssget "_:L" '((0 . "~VIEWPORT"))) ) ) (progn (while (setq ent (ssname sel (setq int (1+ int)))) (setq lst (cons (vlax-ename->vla-object ent) lst)) ) (if (apply 'and (setq mvs (vlax-invoke doc 'copyobjects lst (vla-get-modelspace doc) ) ) ) (progn (mapcar '(lambda (obj) (vla-scaleentity obj pnt scl)) mvs) (mapcar 'vla-delete lst) ) ) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
ziele_o2k Posted August 3, 2017 Author Share Posted August 3, 2017 Hi, Try this program and let me know how you get on with it. (defun c:test (/ doc scl sel int pnt ent lst mvs) ;;------------------------------------;; ;; Tharwat - Date: 26.07.2017 ;; ;; Move objects from Paper Space to ;; ;; Model Space and scale them as per ;; ;; the scale factor specified from ;; ;; the user. ;; ;;------------------------------------;; (if (and (or (/= (getvar 'ctab) "Model") (alert "Command is not allowed in Model Space <!>") ) (setq scl (getdist "\nSpecify the scale factor :")) (princ "\nSelect objects to move to Model space then to scale :") (setq doc (vla-get-activedocument (vlax-get-acad-object)) int -1 pnt (vlax-3d-point '(0. 0. 0.)) sel (ssget "_:L" '((0 . "~VIEWPORT"))) ) ) (progn (while (setq ent (ssname sel (setq int (1+ int)))) (setq lst (cons (vlax-ename->vla-object ent) lst)) ) (if (apply 'and (setq mvs (vlax-invoke doc 'copyobjects lst (vla-get-modelspace doc) ) ) ) (progn (mapcar '(lambda (obj) (vla-scaleentity obj pnt scl)) mvs) (mapcar 'vla-delete lst) ) ) ) ) (princ) ) (vl-load-com) Works great, that is exactly what I need. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 3, 2017 Share Posted August 3, 2017 Works great, that is exactly what I need. Great to hear that. Quote Link to comment Share on other sites More sharing options...
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.