home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 November
/
pcwk_11_98a.iso
/
Wtestowe
/
AutoView
/
AcadInt
/
data1.cab
/
Program_Executable_Files
/
aview14.lsp
< prev
next >
Wrap
Lisp/Scheme
|
1998-01-20
|
17KB
|
659 lines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (C) Copyright 1997 by Autodesk, Inc.
;; By Jessica Tarr and Daren Chung
;; Portions (c)1996, Daryl L. Monk
;;
;; Permission to use, copy, modify, and distribute this software
;; for any purpose and without fee is hereby granted, provided
;; that the above copyright notice appears in all copies and that
;; both that copyright notice and this permission notice appear in
;; all supporting documentation.
;;
;; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;; WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;; PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Global Variable Declaration and Initialization
(setq AVW_REDATTACHED "FALSE")
(setq AVW_FNAME "")
(setq AVW_ARXLOADED "FALSE")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;DXF FUNCTION
(defun dxf (CODE E_LIST)
(cdr (assoc CODE E_LIST))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; XREFSELECT FUNCTION
(defun C:XREFSELECT ( / ENT1 EN ED NAME VJUST HJUST WDTH NAME ELAY ECLR ELIN
STPT ENPT CTRPT RAD ROT TXHT VAL OBLQ JUSTNAM LAYDAT LAYCLR LAYLTYP STYL SBLIP)
;;Preset variables
(setq SBLIP (getvar "BLIPMODE"))
;;Prompt for selection
(if(= AVW_REDATTACHED "TRUE")
(progn
(if (= NOTE 1)
(progn
(setq ENTITY (nentsel "\nPlease select the note then <return>:"))
(setq NOTEREVERSESTR (reverse ENTITY))
(setq BLOCKNAMEID (car NOTEREVERSESTR))
(setq ENTITY (entget (car BLOCKNAMEID) ' ("*")))
)
)
(if (= LINK 1)
(progn
(setq ENTITY (entget (car (nentsel"\nPlease select the link then <return>: ")) ' ("admenote")))
(setq ENTNAMEID (dxf -1 ENTITY))
(setq ENTNAME (dxf 0 ENTITY))
(setq LOOPEND 0)
(if (wcmatch ENTNAME "VERTEX")
(progn
(while (= LOOPEND 0)
(setq ENTNEXTID (entnext ENTNAMEID))
(setq ENTITY (entget ENTNEXTID))
(setq ENTNAME (dxf 0 ENTITY))
(setq ENTNAMEID ENTNEXTID)
(if (wcmatch ENTNAME "*SEQEND*")
(setq LOOPEND 1)
)
)
(setq PLINENAMEID (dxf -2 ENTITY))
(setq ENTITY (entget PLINENAMEID ' ("*")))
)
)
)
)
;;Determine name of entity
(setq NAME (dxf 0 ENTITY) ELAY (dxf 8 ENTITY) ECLR (dxf 62 ENTITY) ELIN (dxf 6 ENTITY))
(getstring)
;;Color bylayer
(if (not ECLR)
(progn
(setq LAYDAT (tblsearch "LAYER" ELAY)
LAYCLR (dxf 62 LAYDAT)
ECLR (strcat "Bylayer: " (itoa LAYCLR))
)
)
(setq ECLR (itoa ECLR))
)
;;Linetype bylayer
(if (not ELIN)
(progn
(setq LAYDAT (tblsearch "LAYER" ELAY)
LAYLTYP (dxf 6 LAYDAT)
ELIN (strcat "Bylayer: " LAYLTYP)
)
)
)
;;Get the XDATA from the Link or Note entities.
(setq data1 (cdr (assoc -3 ENTITY)))
(if (not data1)
(progn
(if (= LINK 1)
(progn
(princ "The selected entity is not a LINK")
)
)
(if (= NOTE 1)
(progn
(princ "The selected entity is not a NOTE")
)
)
)
(progn
(setq data2 (car data1))
(setq data3 (cadr data2))
(setq data4 (cdr data3))
(setq data5 (substr data4 6 256))
(if (= NOTE 1)
(progn
(if (wcmatch ELAY "*ADMENOTE*,*REDLINE_PSPACE*")
(progn
(princ "\nThe contents of this note is: " )
(princ data5)
(princ)
)
)
)
)
(if (= LINK 1)
(progn
(if (wcmatch ELAY "*ADMELINK*,*REDLINE_PSPACE*")
(progn
(princ "\nThe file associated with this link is: " )
(princ data5)
(princ)
)
)
)
)
)
)
;;Start point
(if STPT
(progn
(princ (strcat "\n Start pt: "))
(princ STPT)
)
)
;;End point
(if ENPT
(progn
(princ (strcat "\n End pt: "))
(princ ENPT)
)
)
;;Reset variables
(setq STPT nil ENPT nil STYL nil TXHT nil ROT nil RAD nil CTRPT nil NAME nil VAL nil)
(setvar "BLIPMODE" SBLIP)
(prin1)
)
;;ELSE (!AVW_REDATTACHED)
(progn
(princ "\nThere are no redlines currently attached.")
(princ)
)
)
;; End of XREFSELECT function
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; GETNOTE FUNCTION
(defun c:aviewgetnote ()
(setq NOTE 1)
(setq LINK 0)
(c:xrefselect)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;GETLINK FUNCTION
(defun c:aviewgetlink ()
(setq LINK 1)
(setq NOTE 0)
(c:xrefselect)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;DISPLAY REDLINES FUNCTION
(defun c:aviewredlines()
(setq ORIGLAYER (getvar "clayer"))
(setq AVW_FNAME (getfiled "Choose Redline File" "" "red" 14))
(setq FNAMELEN (strlen AVW_FNAME))
;;Traverse the file name string to derive the base name
;;of the drawing. Find and set the slashpos and dotpos
(setq COUNTER FNAMELEN)
(setq DOTPOS FNAMELEN)
(setq SLASHPOS -1)
(setq bDONE 0)
(while (= bDONE 0)
(if (=(substr AVW_FNAME COUNTER 1) "\\")
(progn
(setq SLASHPOS COUNTER)
(setq bDONE 1)
)
)
(if (= (substr AVW_FNAME COUNTER 1) ".")
(progn
(setq DOTPOS COUNTER)
)
)
(if (= (substr AVW_FNAME COUNTER 1) ":")
(progn
(setq SLASHPOS COUNTER)
(setq bDONE 1)
)
)
(setq COUNTER (- COUNTER 1))
(if (<= COUNTER 0)
(progn
(setq bDONE 1)
)
)
)
;;Create the original basename and basepath from the file name
;;Initialize the variables
(setq BASEPATH "")
(setq BASENAME "")
;;If a slashposition wasn't found, it means we're in the
;;AutoCAD directory and a path is not needed.
(if (= SLASHPOS -1)
(progn
(setq BASENAMELEN (- (strlen AVW_FNAME) 4))
(setq BASENAME (substr AVW_FNAME 1 BASENAMELEN))
)
;;Else if we found a slash in the filename. The basename needs to be parsed
;;from the basename using the slash and dot positions. The basepath is also
;;needed.
(progn
(setq BASENAME (substr AVW_FNAME (+ SLASHPOS 1) (- (- DOTPOS SLASHPOS) 1)))
(setq BASEPATH (substr AVW_FNAME 1 SLASHPOS))
)
)
;;Traverse the basename string looking to see if it's a long filename with spaces
;;Replace the spaces with underscores "_" only for the pupose of naming the block
;;The block is not allowed to have spaces in it. Original filename and basename are not
;;altered.
(setq BASENAMELEN (strlen BASENAME))
(setq UNDERBAR "_")
(setq COUNTER BASENAMELEN)
(setq bDONE 0)
(setq bSPACE 0)
(setq BASENAMEL BASENAME)
(while (= bDONE 0)
(if (=(substr BASENAMEL COUNTER 1) " ")
(progn
(setq SPACEPOS COUNTER)
(setq MINUSSPACE (- SPACEPOS 1))
(setq PLUSSPACE (+ SPACEPOS 1))
(setq BASENAMEL (strcat (strcat (substr BASENAMEL 1 MINUSSPACE) "_")(substr BASENAMEL PLUSSPACE BASENAMELEN)))
(setq bSPACE 1)
(if(= bSPACE 1)
(progn
(setq BASENAMEL (strcat (strcat (substr BASENAMEL 1 MINUSSPACE) "_")(substr BASENAMEL PLUSSPACE BASENAMELEN)))
)
)
)
)
(setq COUNTER (- COUNTER 1))
(if (<= COUNTER 0)
(progn
(setq bDONE 1)
)
)
)
(if(= bSPACE 1)
(progn
(setq BASENAME BASENAMEL)
)
)
;;Need to alter the BLOCKNAME if the combined layer name
;;will exceed 31 characters. Combined name includes
;;BLOCKNAME+_PS|ADMEREDLINE. Rename BASENAME to BLOCKNAME
;;since that's what is really is.
(setq BLOCKNAME BASENAME)
(setq TEMPBLKNAME BLOCKNAME)
;;Check the length of the BLOCKNAME. If it's still
;;to long (ie..greater than 10 characters to be safe), take
;;the last 10 characters to make the BLOCKNAME
(setq BLOCKLEN (strlen TEMPBLKNAME))
(if(>= BLOCKLEN 10)
(progn
(setq STARTPOS (- BLOCKLEN 10))
(setq TEMPBLKNAME2 TEMPBLKNAME)
(setq TEMPBLKNAME (substr TEMPBLKNAME2 STARTPOS BLOCKLEN))
)
)
(setq BLOCKNAME TEMPBLKNAME)
;;Now it's time to try to attach the Xref
(if (= AVW_FNAME nil)
(prompt "\nFunction failed due to incorrect name")
(progn
(command "layer" "new" "ADMEREDLINE" "set" "ADMEREDLINE" "")
(setq INITIALTILEMODE (getvar "TILEMODE"))
(if (= INITIALTILEMODE 1)
(progn
(c:insertmspaceredline)
(c:insertpspaceredline)
(command "tilemode" "1")
)
;; else
(progn
(c:insertpspaceredline)
(c:insertmspaceredline)
(command "tilemode" "0")
)
)
(c:changeblockname)
(command "layer" "lock" "ADMEREDLINE" "")
(setq LAYERCREATED 1)
)
)
(setvar "CLAYER" ORIGLAYER)
(setq NOTE 0)
(setq LINK 0)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;INSERT REDLINE XREF IN MSPACE
(defun c:insertmspaceredline()
;;Get the AutoCAD Environment Variable and save it to a safe place
(setq TEMPENV1 (getenv "ACAD"))
;;Create a copy of the original ACAD Environment variable
(setq TEMPENV2 TEMPENV1)
;;Add a semi-colon to the end of the Environment variable
;;for path separation
(setq TEMPENV2 (strcat TEMPENV2 ";"))
;;Add BASEPATH to the Environment variable
(setq TEMPENV2 (strcat TEMPENV2 BASEPATH))
(setq TEMPENV2 (strcat TEMPENV2 ";"))
;;Save the new ACAD Environment variable
(setenv "ACAD" TEMPENV2)
;;Set the Block name
(strcase BLOCKNAME)
(setq MSPACENAME (strcat BLOCKNAME "="))
(setq MSPACENAME (strcat MSPACENAME AVW_FNAME))
(command "tilemode" "1")
(command "xref" "attach" MSPACENAME "0,0" "" "" "")
;;Modelspace redline is now attached
(setq AVW_REDATTACHED "TRUE")
;;Reset the AutoCAD Environment Variable to its original state
(setenv "ACAD" TEMPENV1)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;INSERT REDLINE XREF IN PSPACE
(defun c:insertpspaceredline()
;;Get the AutoCAD Environment Variable and save it to a safe place
(setq TEMPENV1 (getenv "ACAD"))
;;Create a copy of the original ACAD Environment variable
(setq TEMPENV2 TEMPENV1)
;;Add a semi-colon to the end of the Environment variable
;;for path separation
(setq TEMPENV2 (strcat TEMPENV2 ";"))
;;Add BASEPATH to the Environment variable
(setq TEMPENV2 (strcat TEMPENV2 BASEPATH))
(setq TEMPENV2 (strcat TEMPENV2 ";"))
;;Save the new ACAD Environment variable
(setenv "ACAD" TEMPENV2)
;;Set the Block name
(strcase BLOCKNAME)
(setq PSPACENAME (strcat BLOCKNAME "_ps="))
(setq PSPACENAME (strcat PSPACENAME AVW_FNAME))
(command "tilemode" "0")
(command "xref" "attach" PSPACENAME "0,0" "" "" "")
(command "layer" "freeze" (strcat BLOCKNAME "_PS|*") "")
(command "layer" "thaw" (strcat BLOCKNAME "_PS|__AVIEW__") "")
;;Need to turn on the redline_pspace layers
(command "layer" "thaw" (strcat BLOCKNAME "_PS|REDLINE_PSPACE") "")
;;Need to enable VISRETAIN, since we are freezing/thawing specific xref layers. If user saves base dwg, with redlines
;; xref'ed, the layer settings will be saved only if VISRETAIN=1
(command "visretain" "1")
;;Paperspace redline is now attached
(setq AVW_REDATTACHED "TRUE")
;;Reset the AutoCAD Environment Variable to its original state
(setenv "ACAD" TEMPENV1)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;CHANGE THE BLOCK NAME
(defun c:changeblockname()
;;This function is to alter the block name of the attached xref to strip
;;out the .dwg on the end of the filename so that after saving, the xref
;;will be resolved when the drawing is reloaded.
(setq NEWBLOCKNAME (tblobjname "BLOCK" BLOCKNAME))
(setq RETURN (chgpath NEWBLOCKNAME))
(if (= RETURN 0)
(progn
(princ "\n")
(princ "Unable to sucessfully complete block name change. \n")
(princ "You may be unable to save redlines. \n")
(princ "Please contact technical support.")
(princ "\n")
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;HIDE MODELSPACE REDLINES
(defun c:hidemspaceredlines()
(if (= AVW_REDATTACHED "TRUE")
(progn
(setq CURRENTTILEMODE (getvar "TILEMODE"))
(if (= CURRENTTILEMODE 0)
(progn
(initget "Yes No")
(setq ANSWER (getkword "This command hides Modelspace redlines in viewports (in Tilemode 0). Continue? (Yes or No) "))
(princ ANSWER)
(if (= ANSWER "Yes")
(progn
(command "pspace")
(command "vplayer" "freeze" "ADMEREDLINE" "all" "thaw" "ADMEREDLINE" "current")
(command)
)
(progn
(command)
)
)
)
;ELSE
(progn
(princ "\nThis feature works in paperspace only.")
(princ)
)
)
)
;;Else post a message on the command line if there are no redlines
;;currently attached.
(progn
(princ "\nThere are no redlines currently attached.")
(princ)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;REMOVE REDLINE FUNCTION
(defun c:aviewremoveredline()
(if (= AVW_REDATTACHED "TRUE")
(progn
(command "layer" "unlock" "ADMEREDLINE" "")
(setq SSREDLINE (ssget "X" '(( 8 . "ADMEREDLINE"))))
(setq NUMREDLINES (sslength SSREDLINE))
(setq COUNT 0)
(while (< COUNT NUMREDLINES)
(progn
(setq XREFENT (entget (ssname SSREDLINE COUNT)))
(setq XNAME (dxf 2 XREFENT))
(command "_xref" "detach" XNAME)
(setq JUNK (+ 1 COUNT))
(setq COUNT JUNK)
)
)
(setq AVW_REDATTACHED "FALSE")
)
;;Else post a message on the command line if there are no redlines
;;currently attached.
(progn
(princ "\nThere are no redlines currently attached.")
(princ)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;LOAD AVIEW FROM ACAD FUNCTION
(defun c:aviewload()
(setq dwgfilename (getvar "dwgname"))
(setq dwgpathname (getvar "dwgprefix"))
(setq dwgfilename (strcat dwgpathname dwgfilename))
(setq len (strlen dwgfilename))
(startapp "viewopen.exe" dwgfilename)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;LIST REDLINES FUNCTION
(defun c:aviewlistredlines()
(if (= AVW_REDATTACHED "TRUE")
(progn
(command "layer" "unlock" "ADMEREDLINE" "")
(setq SSRED (ssget "X" '(( 8 . "ADMEREDLINE"))))
(setq NUMRED (sslength SSRED))
(setq COUNT 0)
(princ "\nThere are ")
(princ NUMRED)
(princ " redline files open. ")
(princ "The redline files are: ")
(while (< COUNT NUMRED)
(progn
(setq XREFENTITY (entget (ssname SSRED COUNT)))
(setq XREFENTNAME (dxf 2 XREFENTITY))
(setq JUNK (+ 1 COUNT))
(setq COUNT JUNK)
(princ "\n")
(princ XREFENTNAME)
)
)
)
;;Else post a message on the command line if there are no redlines
;;currently attached.
(progn
(princ "\nThere are no redlines currently attached.")
(princ)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;ADD REDLINE MENU FUNCTION
(defun c:aviewaddtomenu()
;;Load the menus and toolbars if this is a windows environment
(if (wcmatch (getvar "platform") "*Windows*")
(progn
(command "menuload" "aviewred")
(menucmd "P6=+aviewredline.pop1")
(setq LAYERCREATED 0)
(command)
(princ "\n")
)
)
;;Load any ARX applications to be used
(command "arx" "l" "chgblockpath")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;LOAD MENU
(if S::STARTUP
(setq s::startup (append s::startup '((c:aviewaddtomenu)) ))
(defun s::startup ( ) (c:aviewaddtomenu))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;DISPLAY THE REDLINE TOOLBAR
(defun c:aviewdisplaytoolbar()
(command "_toolbar" "Redline Toolbar" "show")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;HANDLE ANY ERRORS
(defun *error*(msg)
(princ "An error has occurred. Please re-install the Autodesk View")
(princ "\n")
(princ "Redlining Import Tool or contact Autodesk Technical Support for")
(princ "\n")
(princ "further information.")
(princ "\n")
)