Author Topic: put drawings to one dwg file  (Read 2673 times)

0 Members and 1 Guest are viewing this topic.

smileforrest

  • Guest
put drawings to one dwg file
« on: October 10, 2015, 01:24:56 AM »
hi guys,
 Can anyone put drawings to one dwg file without open the drawings, on the contrary, LeeMac has writed a program which can put layers into drawings .http://lee-mac.com/layerstodrawings.html
thanks

Coder

  • Swamp Rat
  • Posts: 827
Re: put drawings to one dwg file
« Reply #1 on: October 10, 2015, 04:25:53 AM »
Hi
You can use INSERT command.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: put drawings to one dwg file
« Reply #2 on: October 10, 2015, 04:32:11 AM »
Hi
You can use INSERT command.

You're assuming the OP wants the drawings added into the currently open drawing ... that is not obvious from the question.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Coder

  • Swamp Rat
  • Posts: 827
Re: put drawings to one dwg file
« Reply #3 on: October 10, 2015, 07:08:13 AM »
Hi
You can use INSERT command.

You're assuming the OP wants the drawings added into the currently open drawing ... that is not obvious from the question.
Yes that is what I thought  :-)


smileforrest

  • Guest
Re: put drawings to one dwg file
« Reply #4 on: October 11, 2015, 10:05:59 PM »
Thanks to Coder and Kerry for your attention, my inspiration is come from coworking, maybe one person can work on one or two layers independently, finally, put everyone's achievement(dwg files containing desired layers ) together! When I read LeeMac's progarme, here come the idea!

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: put drawings to one dwg file
« Reply #5 on: October 12, 2015, 08:16:04 AM »
Give this a try
Code - Auto/Visual Lisp: [Select]
  1. (defun c:InsertAll1 ( / dir doc extn spc )
  2.  
  3.     (setq extn "dwg") ;; Extension of files to Insert e.g "dwg"
  4.  
  5.     (if (setq dir (LM:DirectoryDialog (strcat "Select Directory of " (strcase extn) " Files to Insert") nil 512))
  6.         (progn
  7.                   spc (vlax-get-property doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
  8.             )
  9.             (foreach file (vl-directory-files dir (strcat "*." extn) 1)
  10.                 (vla-insertblock spc (vlax-3D-point '(0.0 0.0 0.0)) (strcat dir "\\" file) 1.0 1.0 1.0 0.0)
  11.             )
  12.             (vla-regen doc acallviewports)
  13.         )
  14.         (princ "\n*Cancel*")
  15.     )
  16.     (princ)
  17. )
  18.  
  19. ;;-------------------=={ Directory Dialog }==-----------------;;
  20. ;;                                                            ;;
  21. ;;  Displays a dialog prompting the user to select a folder   ;;
  22. ;;------------------------------------------------------------;;
  23. ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
  24. ;;------------------------------------------------------------;;
  25. ;;  Arguments:                                                ;;
  26. ;;  msg  - message to display at top of dialog                ;;
  27. ;;  dir  - root directory (or nil)                            ;;
  28. ;;  flag - bit coded flag specifying dialog display settings  ;;
  29. ;;------------------------------------------------------------;;
  30. ;;  Returns:  Selected folder filepath, else nil              ;;
  31. ;;------------------------------------------------------------;;
  32.  
  33. (defun LM:DirectoryDialog ( msg dir flag / Shell Fold Self Path )
  34.     (vl-catch-all-apply
  35.         (function
  36.             (lambda ( / ac HWND )
  37.                 (if
  38.                     (setq Shell (vla-getInterfaceObject (setq ac (vlax-get-acad-object)) "Shell.Application")
  39.                           HWND  (vl-catch-all-apply 'vla-get-HWND (list ac))
  40.                           Fold  (vlax-invoke-method Shell 'BrowseForFolder (if (vl-catch-all-error-p HWND) 0 HWND) msg flag dir)
  41.                     )
  42.                     (setq Self (vlax-get-property Fold 'Self)
  43.                           Path (vlax-get-property Self 'Path)
  44.                           Path (vl-string-right-trim "\\" (vl-string-translate "/" "\\" Path))
  45.                     )
  46.                 )
  47.             )
  48.         )
  49.     )
  50.     (if Self  (vlax-release-object  Self))
  51.     (if Fold  (vlax-release-object  Fold))
  52.     (if Shell (vlax-release-object Shell))
  53.     Path
  54. )
  55.  
  56.  
  57.  
  58.  

Anotherone
Code - Auto/Visual Lisp: [Select]
  1. (defun c:InsertAll2 (/ _bbUL _bbUR space temp dir lst)
  2.   ;; Insert all file(s) of specified type and within directory of selected file
  3.   ;; Alan J. Thompson
  4.  
  5.   (defun _bbUL (o / a b)
  6.     (vla-getboundingbox o 'a 'b)
  7.     (list (car (vlax-safearray->list a)) (cadr (vlax-safearray->list b)) 0.)
  8.   )
  9.  
  10.   (defun _bbUR (o / a b) (vla-getboundingbox o 'a 'b) (vlax-safearray->list b))
  11.  
  12.   (setq space (vlax-get (cond (*AcadDoc*)
  13.                               ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
  14.                         )
  15.                         (if (eq (getvar 'CVPORT) 1)
  16.                           'paperspace
  17.                           'modelspace
  18.                         )
  19.               )
  20.   )
  21.  
  22.   (if (setq temp (getfiled "Select file type to import" (getvar 'DWGPREFIX) "" 2))
  23.                     (setq dir (vl-filename-directory temp))
  24.                     (strcat "*" (vl-filename-extension temp))
  25.                     1
  26.                   )
  27.       (if (cadr (setq lst
  28.                        (cons (vlax-invoke
  29.                                space
  30.                                'insertblock
  31.                                '(0. 0. 0.)
  32.                                (strcat dir "\\" file)
  33.                                1.
  34.                                1.
  35.                                1.
  36.                                0.
  37.                              )
  38.                              lst
  39.                        )
  40.                 )
  41.           )
  42.         (vlax-invoke (car lst) 'move (_bbUL (car lst)) (mapcar '+ (_bbUR (cadr lst)) '(1. 0. 0.)))
  43.       )
  44.     )
  45.   )
  46.   (princ)
  47. )

And This one
Code - Auto/Visual Lisp: [Select]
  1. (defun c:insertblks (/ d doc lst pt pt1 dir)
  2.   (if
  3.     (and (setq
  4.        dir (vl-filename-directory
  5.          (getfiled "Select a DWG" (getvar 'dwgprefix) "dwg" 8)
  6.            )
  7.      )
  8.      (setq lst (vl-directory-files dir "*.dwg"))
  9.      (setq pt1 (getpoint "\nSelect point for first block: "))
  10.      (setq d
  11.         (distance (getpoint pt1 "\nSelect distance to space blocks: ")
  12.               pt1
  13.         )
  14.      )
  15.     )
  16.      (foreach b    lst
  17.        (vla-insertblock
  18.      (if (= (getvar 'cvport) 1)
  19.        (vla-get-paperspace doc)
  20.        (vla-get-modelspace doc)
  21.      )
  22.      (vlax-3d-point (setq pt1 (polar pt1 0.0 d)))
  23.      (strcat dir "\\" b)
  24.      1
  25.      1
  26.      1
  27.      0.0
  28.        )
  29.      )
  30.   )
  31.   (princ)
  32. )

smileforrest

  • Guest
Re: put drawings to one dwg file
« Reply #6 on: October 14, 2015, 02:48:46 AM »
Thank you HasanCAD,

The first routine runs well,and dwgs inserted become blocks;
The soncend routine cann't run, and when choose dwgs we need choose one by one ,cann't choose multifiles one time.

thanks again.