Results 1 to 2 of 2

Thread: Dividir um desenho em partes iguais

  1. #1
    Login to Give a bone
    0

    Question Dividir um desenho em partes iguais

    Caros amigos, gostaria de saber de que forma poderia através de autolisp, dividir um desenho em partes iguais (por exemplo, 9, dividindo o desenho em 3x3), criando automaticamente 9 DWGs numa determinada pasta, e mantendo as coordenadas originais, isto é, se voltassem a ser inseridos como blocos num novo novo desenho, se ligassem na perfeição. Nota: não necessito de Trim na divisão dos desenhos. O que me importa é não perder informação. Obrigado pela ajuda.

  2. #2
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Dividir um desenho em partes iguais

    If I may ask, why do you need to split DWG, and then compose it again with the same info ?

    If DWG is too large, you can pack it with zip, and then if it's again too large split archive into several parts. When you want to use DWG, you can compose these parts into zip and then unpack it and have complete DWG...

    If you need exactly what you said, you can use "WBLOCK" command with selection of objects that are within each one of 3x3 windows... This code will try to grab 3x3=9 dwg files in specified folder, but because of the thing that you want whole objects - not trimmed and because of required "CP" - crossing polygon selection mode, there may be less than 9 DWG during export... Routine ensures firstly that DWG is saved as active document, then erases all objects in model space, xref attaches previously exported files and saves again new DWG with filename "dwgname-rcall.dwg" in specified directory where are also other exported dwg xref files stored...

    Code:
    (defun c:splitdwg3x3 ( / dwgn dwgname path fildia osm aobj adoc avp vpw vph vpcenpt ptll ptur rc1s rc1e rc2s rc2e rc3s rc3e rc4s rc4e rc5s rc5e rc6s rc6e rc7s rc7e rc8s rc8e rc9s rc9e )
      (vl-load-com)
      (setq dwgn (getvar 'dwgname))
      (setq dwgname (substr dwgn 1 (- (strlen dwgn) 4)))
      (setq fildia (getvar 'filedia))
      (setq osm (getvar 'osmode))
      (setvar 'osmode 0)
      (setvar 'tilemode 1)
      (vl-cmdf "_.zoom" "e")
      (setq aobj (vlax-get-acad-object)
            adoc (vla-get-activedocument aobj)
            avp (vla-get-activeviewport adoc)
            vpw (vla-get-width avp)
            vph (vla-get-height avp)
            vpcenpt (vlax-safearray->list (vlax-variant-value (vla-get-center avp)))
            ptll (mapcar '- vpcenpt (list (/ vpw 2) (/ vph 2)))
            ptur (mapcar '+ vpcenpt (list (/ vpw 2) (/ vph 2)))
      )
      (vla-save adoc)
      (setq rc1s ptll
            rc1e (mapcar '+ ptll (list (/ vpw 3) (/ vph 3)))
            rc2s (mapcar '+ ptll (list 0. (/ vph 3)))
            rc2e (mapcar '+ ptll (list (/ vpw 3) (* (/ vph 3) 2)))
            rc3s (mapcar '+ ptll (list 0. (* (/ vph 3) 2)))
            rc3e (mapcar '+ ptll (list (/ vpw 3) vph))
            rc4s (mapcar '+ ptll (list (/ vpw 3) 0.))
            rc4e (mapcar '+ ptll (list (* (/ vpw 3) 2) (/ vph 3)))
            rc5s (mapcar '+ ptll (list (/ vpw 3) (/ vph 3)))
            rc5e (mapcar '+ ptll (list (* (/ vpw 3) 2) (* (/ vph 3) 2)))
            rc6s (mapcar '+ ptll (list (/ vpw 3) (* (/ vph 3) 2)))
            rc6e (mapcar '+ ptll (list (* (/ vpw 3) 2) vph))
            rc7s (mapcar '+ ptll (list (* (/ vpw 3) 2) 0.))
            rc7e (mapcar '+ ptll (list vpw (/ vph 3)))
            rc8s (mapcar '+ ptll (list (* (/ vpw 3) 2) (/ vph 3)))
            rc8e (mapcar '+ ptll (list vpw (* (/ vph 3) 2)))
            rc9s (mapcar '+ ptll (list (* (/ vpw 3) 2) (* (/ vph 3) 2)))
            rc9e ptur
      )
    ;  (vl-cmdf "_.rectangle" rc1s rc1e)
    ;  (vl-cmdf "_.rectangle" rc2s rc2e)
    ;  (vl-cmdf "_.rectangle" rc3s rc3e)
    ;  (vl-cmdf "_.rectangle" rc4s rc4e)
    ;  (vl-cmdf "_.rectangle" rc5s rc5e)
    ;  (vl-cmdf "_.rectangle" rc6s rc6e)
    ;  (vl-cmdf "_.rectangle" rc7s rc7e)
    ;  (vl-cmdf "_.rectangle" rc8s rc8e)
    ;  (vl-cmdf "_.rectangle" rc9s rc9e)
      (setvar 'filedia 0)
      (if (not (vl-catch-all-error-p (setq path (vl-catch-all-apply 'vl-filename-directory (list (getfiled "Select destination directory for 3x3 dwg split export - pick one file in desired folder" "" "" 4))))))
      (progn
      (vl-cmdf "_.-wblock" (strcat path "\\" dwgname "-rc1.dwg") "" rc1s "CP" rc1e (list (car rc1e) (cadr rc1s)) rc1s (list (car rc1s) (cadr rc1e)) "")
      (vl-cmdf "_.-wblock" (strcat path "\\" dwgname "-rc2.dwg") "" rc2s "CP" rc2e (list (car rc2e) (cadr rc2s)) rc2s (list (car rc2s) (cadr rc2e)) "")
      (vl-cmdf "_.-wblock" (strcat path "\\" dwgname "-rc3.dwg") "" rc3s "CP" rc3e (list (car rc3e) (cadr rc3s)) rc3s (list (car rc3s) (cadr rc3e)) "")
      (vl-cmdf "_.-wblock" (strcat path "\\" dwgname "-rc4.dwg") "" rc4s "CP" rc4e (list (car rc4e) (cadr rc4s)) rc4s (list (car rc4s) (cadr rc4e)) "")
      (vl-cmdf "_.-wblock" (strcat path "\\" dwgname "-rc5.dwg") "" rc5s "CP" rc5e (list (car rc5e) (cadr rc5s)) rc5s (list (car rc5s) (cadr rc5e)) "")
      (vl-cmdf "_.-wblock" (strcat path "\\" dwgname "-rc6.dwg") "" rc6s "CP" rc6e (list (car rc6e) (cadr rc6s)) rc6s (list (car rc6s) (cadr rc6e)) "")
      (vl-cmdf "_.-wblock" (strcat path "\\" dwgname "-rc7.dwg") "" rc7s "CP" rc7e (list (car rc7e) (cadr rc7s)) rc7s (list (car rc7s) (cadr rc7e)) "")
      (vl-cmdf "_.-wblock" (strcat path "\\" dwgname "-rc8.dwg") "" rc8s "CP" rc8e (list (car rc8e) (cadr rc8s)) rc8s (list (car rc8s) (cadr rc8e)) "")
      (vl-cmdf "_.-wblock" (strcat path "\\" dwgname "-rc9.dwg") "" rc9s "CP" rc9e (list (car rc9e) (cadr rc9s)) rc9s (list (car rc9s) (cadr rc9e)) "")
      (vl-cmdf "_.erase" (ssget "_X" '((410 . "Model"))) "")
      (vl-cmdf "_.-xref" "A" (strcat path "\\" dwgname "-rc1.dwg") rc1s "" "" "")
      (vl-cmdf "_.-xref" "A" (strcat path "\\" dwgname "-rc2.dwg") rc2s "" "" "")
      (vl-cmdf "_.-xref" "A" (strcat path "\\" dwgname "-rc3.dwg") rc3s "" "" "")
      (vl-cmdf "_.-xref" "A" (strcat path "\\" dwgname "-rc4.dwg") rc4s "" "" "")
      (vl-cmdf "_.-xref" "A" (strcat path "\\" dwgname "-rc5.dwg") rc5s "" "" "")
      (vl-cmdf "_.-xref" "A" (strcat path "\\" dwgname "-rc6.dwg") rc6s "" "" "")
      (vl-cmdf "_.-xref" "A" (strcat path "\\" dwgname "-rc7.dwg") rc7s "" "" "")
      (vl-cmdf "_.-xref" "A" (strcat path "\\" dwgname "-rc8.dwg") rc8s "" "" "")
      (vl-cmdf "_.-xref" "A" (strcat path "\\" dwgname "-rc9.dwg") rc9s "" "" "")
      (vl-cmdf "_.saveas" "" (strcat path "\\" dwgname "-rcall.dwg"))
      ))
      (setvar 'filedia fildia)
      (setvar 'osmode osm)
      (princ)						
    )
    Hope this helps, M.R.
    Last edited by marko_ribar; 2011-08-22 at 02:37 PM. Reason: fixed possible nil input (setq path nil)

Similar Threads

  1. Divisão de desenho em partes iguais
    By caldeira.istec107850 in forum AutoLISP
    Replies: 0
    Last Post: 2011-08-21, 04:00 PM
  2. Dividir terrenos con civil 3d
    By pgsilvestre in forum AutoCAD Civil 3D - General
    Replies: 0
    Last Post: 2009-09-21, 10:20 PM
  3. Coordenadas em desenho
    By yesluis in forum AutoCAD General
    Replies: 1
    Last Post: 2009-06-08, 11:32 PM
  4. DESENHO SANCA
    By batista in forum AutoCAD General
    Replies: 1
    Last Post: 2009-01-29, 05:35 PM
  5. Dividir Uma Linha e Numerar as Divisões
    By galeguu in forum AutoCAD General
    Replies: 3
    Last Post: 2008-11-01, 01:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •