home *** CD-ROM | disk | FTP | other *** search
- ; Sample.lsp
- ; Release 1.0
- ; Rick Gardner
- ;
- ; .............................................................................
- ;
- ; Copyright (c) 1998 by Visio Corporation. All rights reserved.
- ;
- ; The Software is subject to the license agreement that accompanies
- ; or is included with the Software, which specifies the permitted
- ; and prohibited uses of the Software. Any unauthorized duplication
- ; or use of Visio Corporation Software, in whole or in part, in print,
- ; or in any other storage and retrieval system is prohibited.
- ;
- ; To the maximum extent permitted by applicable law, Visio Corporation
- ; and its suppliers disclaim any and all warranties and conditions,
- ; either express or implied, including, without limitation, implied
- ; warranties of merchantability, fitness for a particular purpose,
- ; title, and non-infringement, and those arising out of usage of trade
- ; or course of dealing, concerning these materials. These materials
- ; are provided "as is" without warranty of any kind.
- ; .............................................................................
-
-
- ;*********************************************************************
- ; CAD DXF TRANSLATOR/WRITER FOR STEPPING THROUGH DRAWING ENTITIES
- ;*********************************************************************
- (defun c:dxfread ( / picklist ans ent vname ss ckent filnam )
- (setq ans "S")
- (while (and (/= ans "") (/= ans "Q"))
- (if (= ans "V")
- (if (setq vname (eval (read (getstring "\nEnter variable name to use: "))))
- (progn
- (if (= (type vname) 'ENAME)
- (setq ent vname)
- )
- (if (= (type vname) 'LIST)
- (setq ent (cdr (assoc -1 vname)))
- )
- (setq picklist (cons ent picklist))
- )
- (princ "\n**********Variable name not valid**************")
- )
- )
- (if (= ans "D") (progn
- (setq ss (ssget "X")
- ckent (ssname ss (- (sslength ss) 1))
- )
- (if (eq ckent ent)
- (princ "\n********First entity in DWG encountered********")
- (while ckent
- (if (eq (entnext ckent) ent)
- (setq ent ckent
- picklist (cons ent picklist)
- ckent nil
- )
- (setq ckent (entnext ckent))
- )
- )
- )
- ))
- (if (= ans "W") (progn
- (setq filnam (getstring "\nEnter name of file to write: "))
- (setq fil (open filnam "w"))
- (princ (strcat "\nCommand is EM to read modified entity data from " filnam " and perform entmake."))
- ))
- (if (= ans "P") (if (setq picklist (cdr picklist))
- (setq ent (car picklist))
- (princ "\n********Beginning of picklist encountered********")
- )
- )
- (if (= ans "N") (if (entnext ent) (progn
- (setq ent (entnext ent))
- (setq picklist (cons ent picklist))
- ) ;progn
- (princ "\n********Last entity in DWG encountered********")
- )
- )
- (if (= ans "L") (progn
- (setq ent (entlast))
- (while (entnext ent) (setq ent (entnext ent)))
- (setq picklist (cons ent picklist))
- ))
- (if (= ans "S") (progn
- (setq ent (car (entsel)))
- (if picklist
- (setq picklist (cons ent picklist))
- (setq picklist (list ent))
- ); if
- );progn
- )
- (setq elist (entget ent (list "*")))
- (if (not (member (cdr (assoc 0 elist)) '("VERTEX" "ATTRIB" "SEQEND")))
- (redraw ent 3)
- )
- (setq count 1)
- (while (car elist)
- (if (= (caar elist) -3) (progn
- (setq elist (cdar elist))
- (while (setq xlist (car elist))
- (while (car xlist)
- (if (= ans "W")(progn
- (prin1 (car xlist) fil)
- (write-char 10 fil)
- )(progn
- (print (car xlist))
- ))
- (setq xlist (cdr xlist))
- (setq count (+ 1 count))
- ;(if (and (/= ans "W") (> count 23)) (progn
- ; (TEXTSCR)
- ; (getstring "\nHit enter to continue")
- ; (setq count 1)
- ;))
- )
- (setq elist (cdr elist))
- )
- (if (car elist)
- (if (= ans "W") (progn
- (prin1 (car elist) fil)
- (write-char 10 fil)
- )(progn
- (print (car elist))
- ))
- )
- )(progn
- (if (= ans "W") (progn
- (prin1 (car elist) fil)
- (write-char 10 fil)
- )(progn
- (print (car elist))
- ))
- ));progn,if
- (princ)
- (setq count (+ 1 count))
- ;(if (and (/= ans "W") (> count 23)) (progn
- ; (TEXTSCR)
- ; (getstring "\nHit enter to continue")
- ; (setq count 1)
- ;))
- (setq elist (cdr elist))
- )
- (TEXTSCR)
- (if (= ans "W") (close fil))
- (setq ans (strcase (getstring "\nWrite, Next, Select, prev Pick, prev Dwg, Last dwg, Var or Quit? <Q> ")))
- );while
- (GRAPHSCR)
- (redraw)
- ) ;defun
- (princ "\nDXFREAD loaded")
- ;*********************************************************************
- ;COMPANION TO PREVIOUS FUNCTION FOR MAKING ENT FROM A FILE
- ;*********************************************************************
- (defun c:dxfemake ( / )
- (setq filnam (findfile (getstring "\nEnter name of file to read for entmake: ")))
- (if (not filnam) (progn
- (alert (strcat "File " filnam " not found."))
- (quit)
- ))
- (setq elist nil xlist nil)
- (setq fil (open filnam "r"))
- (while (setq ln (read-line fil))
- (if (not (wcmatch ln "*<Entity name:*"))(progn
- (setq ln (read ln))
- (if (and (not xlist) (= (type ln) 'LIST)) ;std cad data
- (if elist (setq elist (cons ln elist))
- (setq elist (list ln))
- )
- )
- (if (and xlist (= (type ln) 'STR))(progn ;not 1st xdata appname
- (setq xlist (reverse xlist))
- (setq xlist (cons (list ln) xlist))
- (setq xlist (reverse xlist))
- (regapp ln)
- ))
- (if (and (not xlist) (= (type ln) 'STR))(progn;1st xdata appname
- (setq xlist (list -3 (list ln)))
- (regapp ln)
- ))
- (if (and xlist (= (type ln) 'LIST))(progn ;xdata info
- (setq xlist (reverse xlist))
- (setq xlist (cons (reverse (cons ln (reverse (car xlist)))) (cdr xlist)))
- (setq xlist (reverse xlist))
- ))
- ));progn,if
- );while
- (close fil)
- (if xlist (setq elist (cons xlist elist)))
- (setq elist (reverse elist))
- (if (entmake elist)
- (princ (strcat "\nEntmake successful from file " filnam "."))
- (progn
- (princ (strcat "\nEntmake failed from file " filnam ". ERRNO is: "))
- (princ (getvar "ERRNO"))
- ))
- (princ)
- );defun
- (princ "\tDXFEMAKE loaded")
- ;*********************************************************************
- ;FUNCTION TO UPDATE ALL BLOCK DEFINITIONS IN DRAWING
- ;*********************************************************************
- (defun c:redoblks ( / blist belist rauto)
- (if (setq blist (cdr (assoc 2 (tblnext "BLOCK" T)))) (progn
- (setq blist (list blist))
- (while (setq belist (tblnext "BLOCK"))
- (setq blist (cons (cdr (assoc 2 belist)) blist))
- )
- (setq rauto (getvar "regenmode"))
- (setvar "regenmode" 0)
- (foreach blk blist
- (if (findfile (strcat blk ".DWG")) (progn
- (setq blk (strcat blk "="))
- (command "insert" blk)
- (command)
- ))
- )
- (setvar "regenmode" rauto)
- (COMMAND "REGEN")
- (PRINC "\nAll block definitions updated.")
- ))
- (princ)
- );DEFUN
- (princ "\nREDOBLKS loaded")
-
- ;*********************************************************************
- ;COMMAND TO ECHO BACK BLOCK AND FILE DATA
- ;*********************************************************************
- (defun c:find ( / filenam gotit count)
- (setq filenam (getstring "\nEnter name and extension (if not .DWG) to locate: "))
- (setq count 1 gotit nil)
- (while (< count (strlen filenam))
- (setq x (substr filenam count 1))
- (if (= x ".") (setq gotit 1))
- (setq count (+ 1 count))
- )
- (if (not gotit) (setq filenam (strcat filenam ".DWG")))
- (if (findfile filenam) (progn
- (princ (strcat "\nFile found file as " (findfile filenam)))
- (if (tblsearch "block" (substr filenam 1 (- (strlen filenam) 4)))
- (princ " and as block in current drawing")
- )
- (princ ".")
- ) ;progn
- (princ (strcat "\nFile " filenam " not found."))
- )
- (princ)
- );defun
- (princ "\tFIND loaded")
- (princ)
-