Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2DREP AutoLIsp Routine

1 REPLY 1
Reply
Message 1 of 2
Anonymous
1298 Views, 1 Reply

2DREP AutoLIsp Routine

My company wants to do the following:

1) open a subdirectory

2) open each drawing in that subdirectory

3) 2DREP the drawing

4) detach the XREF's

5) save the drawing

6) close the drawing

7) open the next drawing in the subdirectory

😎 repeat steps 1-7 until all drawings have been processed

 

I can muddle through writing a lisp routine to do this but have no idea how to make it complete each drawing in the subdirectory. I can write a routine but theuser must open each drawing manually.

 

Any help would be appreciated.

1 REPLY 1
Message 2 of 2
kefer_kb
in reply to: Anonymous

Hello,

i have some lisp files for modifying many drawings like plotting, change title-block, etc.

 

Here is a template for you:

 

;-------------------------------------------------------------------------
;globale Variablen
; INT:        int_lispinit    altueller Wert von 'lispinit'
; STRING:       str_pfad    Pfad fuer DWG-Verzeichniss
; LIST:        list_dwg    Liste mit allen DWG-Zeichnungsnamen ohne Pfad
;-------------------------------------------------------------------------
;Funktion
(defun c:functionname ( / int_lispinit str_pfad list_dwg)
  (vl-load-com)
 
  ;----- aktuelle Systemvariablenwerte sichern
  ;----- save system variables
  (setq old_lispinit (getvar "lispinit"))

  ;----- Systemvariablen veraendern
  ;----- modify ACAD variables
  (setvar "cmdecho" 0)          ;Command echo: aus
  (setvar "lispinit" 0)         ;LISP-Prg. Speicherresistent
  (setvar "sdi" 1)              ;Single Document Interface

  ;----- Abfrage: Verzeichnis mit getfiled
  ;----- Userinput: select directory with getfiled
  (setq str_pfad (gfm-getFolder "Ordner mit allen Zeichnungen zum Bearbeiten:" ""))

  ;----- Liste mit allen Zeichnungsnamen im Verzeichnis bilden
  ;----- create list with all drawings into directory
  (setq list_dwg (vl-directory-files str_pfad "*.dwg" 1))

  ;----- Schleife: Jede Zeichnung öffnen und bearbeiten
  ;----- loop: open each drawing and modify it
  (foreach str_Zeichnung list_dwg

    ;----- Zeichnung öffnen
    ;----- open dwg
    (if (> (getvar "DBMOD") 0)
      (command "_.open" "_y" (strcat str_pfad "\\" str_Zeichnung))
      (command "_.open" (strcat str_pfad "\\" str_Zeichnung))
    );endif

    ;----- Zeichnung bearbeiten
    ;----- modify drawing
    (<your-function>)

    ;----- Zeichnung speichern
    ;----- save drawing
    (command "_.qsave")

  );end foreach

  ;----- Systemvariablen-Werte wiederherstellen
  ;----- restore variables
  (setvar "sdi" 0)
  (setvar "lispinit" old_lispinit)
  (setvar "cmdecho" 1)

  (princ)
);enddefun
;-------------------------------------------------------------------------
;Titel:      GFM-GETFOLDER fuer ACAD2000-2008
;Erklaerung: Funktion öffnet den Windowsdialog zum Auswählen eines Verzeichnisses
;Datum:      Feb. 2009
;Autor:      Ing. Franz Kefer
;-------------------------------------------------------------------------
;lokale VARIABLEN
;VLA-Objekt:    objShell    Shell Objekt
;        folder        Ordner
;        objFolder    Ordner Objekt
; STRING:    str_Path    Ausgewählter Ordner(pfad)
;-------------------------------------------------------------------------
; AUFRUF:        (gfm-getFolder str_Kommentar str_rootDir)
; Argumente:    str_Kommentar    Kommentar im Windows Ordnerdialogfeld
;        str_rootDir    Vorgabeverzeichnis oder Laufwerk für Ordnerauswahl
;-------------------------------------------------------------------------
(defun gfm-getFolder (str_Kommentar str_rootDir / objShell folder objFolder str_Path)

  ;----- Vorbild aus VB
  ;set ShellApp=CreateObject("Shell.Application") 'erzeuge ein neues Objekt "Shell Application"
  ;set FolBrowser=ShellApp.BrowseForFolder(0,"Wähle einen Ordner",16,0) '16 = zusätzl. Ordnerfeld wird angezeigt
 
  ;----- VL-Extension laden
  (vl-load-com)

  ;----- Shell Objekt
  (if (setq obj_Shell (vla-getinterfaceobject (vlax-get-acad-object) "shell.application"))
    (progn
      ;----- Ordner Objekt bestimmen
      (setq folder (vlax-invoke-method obj_Shell 'browseforfolder 0 str_Kommentar 0 str_rootDir))
      ;----- Shell Objekt beenden
      (vlax-release-object obj_Shell)
      ;----- Ordnerpfad auslesen
      (if folder
    (progn
      (setq obj_Folder (vlax-get-property folder 'self))
      (setq str_Path (vlax-get-property obj_Folder 'path))
      (vlax-release-object obj_Folder)
      (vlax-release-object folder)
    );end progn
    ;ELSE
    (quit)
      );end if
    );endprogn
 );endif

  ;----- Rückgabewert
  str_Path
);enddefun

 

kind regards,

Franz

www.gfm.at

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost