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 >
Lisp/Scheme  |  1998-01-20  |  17KB  |  659 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;   (C) Copyright 1997 by Autodesk, Inc.
  3. ;;   By Jessica Tarr and Daren Chung
  4. ;;   Portions (c)1996, Daryl L. Monk
  5. ;;
  6. ;;   Permission to use, copy, modify, and distribute this software 
  7. ;;   for any purpose and without fee is hereby granted, provided 
  8. ;;   that the above copyright notice appears in all copies and that 
  9. ;;   both that copyright notice and this permission notice appear in 
  10. ;;   all supporting documentation.
  11. ;;      
  12. ;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
  13. ;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
  14. ;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
  15. ;;
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17. ;;Global Variable Declaration and Initialization
  18.  
  19.     (setq AVW_REDATTACHED "FALSE")
  20.     (setq AVW_FNAME "")
  21.     (setq AVW_ARXLOADED "FALSE")
  22.     
  23.  
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  25. ;;DXF FUNCTION
  26.  
  27. (defun dxf (CODE E_LIST)
  28.   (cdr (assoc CODE E_LIST))
  29. )
  30.  
  31. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  32. ;; XREFSELECT FUNCTION
  33.                         
  34. (defun C:XREFSELECT ( / ENT1 EN ED NAME VJUST HJUST WDTH NAME ELAY ECLR ELIN
  35.         STPT ENPT CTRPT RAD ROT TXHT VAL OBLQ JUSTNAM LAYDAT LAYCLR LAYLTYP STYL SBLIP)
  36.  
  37. ;;Preset variables
  38.  
  39.     (setq SBLIP (getvar "BLIPMODE"))
  40.  
  41.  
  42. ;;Prompt for selection
  43. (if(= AVW_REDATTACHED "TRUE")
  44. (progn
  45.     (if (= NOTE 1)
  46.         (progn
  47.             (setq ENTITY (nentsel "\nPlease select the note then <return>:"))
  48.             (setq NOTEREVERSESTR (reverse ENTITY))
  49.             (setq BLOCKNAMEID (car NOTEREVERSESTR))
  50.             (setq ENTITY (entget (car BLOCKNAMEID) ' ("*")))
  51.         )
  52.         
  53.     )
  54.     (if (= LINK 1)
  55.  
  56.         (progn
  57.             (setq ENTITY (entget (car (nentsel"\nPlease select the link then <return>: ")) ' ("admenote")))
  58.             (setq ENTNAMEID (dxf -1 ENTITY))
  59.             (setq ENTNAME (dxf 0 ENTITY))
  60.             (setq LOOPEND 0)
  61.  
  62.             (if (wcmatch ENTNAME "VERTEX")
  63.                 (progn
  64.                     (while (= LOOPEND 0)
  65.                         (setq ENTNEXTID (entnext ENTNAMEID))
  66.                         (setq ENTITY (entget ENTNEXTID))
  67.                         (setq ENTNAME (dxf 0 ENTITY))
  68.                         (setq ENTNAMEID ENTNEXTID)
  69.  
  70.                         (if (wcmatch ENTNAME "*SEQEND*")
  71.                             (setq LOOPEND 1)
  72.                         )
  73.                     )
  74.  
  75.                     (setq PLINENAMEID (dxf -2 ENTITY))
  76.                     (setq ENTITY (entget PLINENAMEID ' ("*")))
  77.                 )
  78.             )
  79.  
  80.         )        
  81.         
  82.     )
  83.  
  84. ;;Determine name of entity
  85.  
  86.     (setq NAME (dxf 0 ENTITY)  ELAY (dxf 8 ENTITY) ECLR (dxf 62 ENTITY) ELIN (dxf 6 ENTITY))
  87.        (getstring)
  88.  
  89. ;;Color bylayer
  90.  
  91.     (if (not ECLR) 
  92.         (progn
  93.             (setq LAYDAT (tblsearch "LAYER" ELAY)
  94.             LAYCLR (dxf 62 LAYDAT)
  95.             ECLR (strcat "Bylayer: " (itoa LAYCLR))
  96.                 )
  97.           )
  98.  
  99.               (setq ECLR (itoa ECLR))
  100.         )
  101.  
  102. ;;Linetype bylayer
  103.  
  104.     (if (not ELIN) 
  105.         (progn                                             
  106.             (setq LAYDAT (tblsearch "LAYER" ELAY)
  107.             LAYLTYP (dxf 6 LAYDAT)
  108.             ELIN (strcat "Bylayer: " LAYLTYP)
  109.         )
  110.     )
  111.     )
  112.  
  113.  
  114. ;;Get the XDATA from the Link or Note entities.
  115.  
  116.         (setq data1 (cdr (assoc -3 ENTITY)))
  117.         (if (not data1)
  118.             (progn
  119.                 (if (= LINK 1)
  120.                     (progn
  121.                         (princ "The selected entity is not a LINK")
  122.                     )
  123.                 )
  124.                 
  125.                 (if (= NOTE 1)
  126.                     (progn
  127.                         (princ "The selected entity is not a NOTE")        
  128.                     )
  129.                 )
  130.             )
  131.             (progn
  132.                 (setq data2 (car data1))
  133.                 (setq data3 (cadr data2))
  134.                 (setq data4 (cdr data3))
  135.                 (setq data5 (substr data4 6 256))
  136.  
  137.                 (if (= NOTE 1)
  138.                     (progn
  139.                         (if (wcmatch ELAY "*ADMENOTE*,*REDLINE_PSPACE*")
  140.                             (progn
  141.                                 (princ "\nThe contents of this note is: " )
  142.                                 (princ data5)
  143.                                 (princ)
  144.                             )
  145.                         )
  146.                     )
  147.                 )
  148.                 (if (= LINK 1)
  149.                     (progn
  150.                         (if (wcmatch ELAY "*ADMELINK*,*REDLINE_PSPACE*")
  151.                             (progn
  152.                                 (princ "\nThe file associated with this link is: " )
  153.                                 (princ data5)
  154.                                 (princ)
  155.                             )
  156.                         )
  157.                     )
  158.                 )
  159.             )
  160.         )
  161.  
  162.  
  163. ;;Start point
  164.  
  165.     (if STPT 
  166.         (progn
  167.             (princ (strcat "\n    Start pt: "))
  168.             (princ STPT)
  169.               )
  170.         )
  171.  
  172. ;;End point
  173.  
  174.     (if ENPT 
  175.         (progn 
  176.             (princ (strcat "\n    End pt: "))
  177.             (princ ENPT)
  178.               )
  179.     )
  180.  
  181.  
  182. ;;Reset variables
  183.  
  184.     (setq STPT nil ENPT nil STYL nil TXHT nil ROT nil RAD nil CTRPT nil NAME nil VAL nil)
  185.     (setvar "BLIPMODE" SBLIP)
  186.       (prin1)
  187.  
  188. )
  189. ;;ELSE (!AVW_REDATTACHED)
  190. (progn
  191.     (princ "\nThere are no redlines currently attached.")
  192.     (princ)
  193. )
  194. )
  195.     
  196. ;; End of XREFSELECT function
  197.  
  198. )
  199.  
  200. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  201. ;; GETNOTE FUNCTION
  202.  
  203. (defun c:aviewgetnote ()    
  204.  
  205.     (setq NOTE 1)
  206.     (setq LINK 0)
  207.     (c:xrefselect)
  208.  
  209. )
  210.  
  211. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  212. ;;GETLINK FUNCTION
  213.  
  214. (defun c:aviewgetlink ()
  215.  
  216.     (setq LINK 1)
  217.     (setq NOTE 0)
  218.     (c:xrefselect)
  219.  
  220. )
  221.  
  222. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  223. ;;DISPLAY REDLINES FUNCTION
  224.  
  225. (defun c:aviewredlines()
  226.  
  227.     (setq ORIGLAYER (getvar "clayer"))
  228.     (setq AVW_FNAME (getfiled "Choose Redline File" "" "red" 14))
  229.     (setq FNAMELEN (strlen AVW_FNAME))
  230.  
  231. ;;Traverse the file name string to derive the base name
  232. ;;of the drawing. Find and set the slashpos and dotpos
  233.  
  234.     (setq COUNTER FNAMELEN)
  235.     (setq DOTPOS FNAMELEN)
  236.     (setq SLASHPOS -1)
  237.     (setq bDONE 0)
  238.  
  239.     (while (= bDONE 0)
  240.         (if (=(substr AVW_FNAME COUNTER 1) "\\")
  241.             (progn
  242.                 (setq SLASHPOS COUNTER)
  243.                 (setq bDONE 1)
  244.             )
  245.         )
  246.         (if (= (substr AVW_FNAME COUNTER 1) ".")
  247.             (progn
  248.                 (setq DOTPOS COUNTER)    
  249.             )
  250.         )    
  251.  
  252.         (if (= (substr AVW_FNAME COUNTER 1) ":")
  253.             (progn
  254.                 (setq SLASHPOS COUNTER)
  255.                 (setq bDONE 1)
  256.             )
  257.         )
  258.         (setq COUNTER (- COUNTER 1))
  259.         
  260.         (if (<= COUNTER 0)
  261.             (progn
  262.                 (setq bDONE 1)
  263.             )
  264.         )
  265.     )
  266.  
  267. ;;Create the original basename and basepath from the file name
  268.  
  269.     ;;Initialize the variables
  270.     (setq BASEPATH "")
  271.     (setq BASENAME "")
  272.     
  273.     ;;If a slashposition wasn't found, it means we're in the 
  274.     ;;AutoCAD directory and a path is not needed.
  275.     (if (= SLASHPOS -1)
  276.         (progn
  277.             (setq BASENAMELEN (- (strlen AVW_FNAME) 4))
  278.             (setq BASENAME (substr AVW_FNAME 1 BASENAMELEN))
  279.         )
  280.  
  281.     ;;Else if we found a slash in the filename. The basename needs to be parsed 
  282.     ;;from the basename using the slash and dot positions. The basepath is also
  283.     ;;needed.
  284.         (progn
  285.             (setq BASENAME (substr AVW_FNAME (+ SLASHPOS 1) (- (- DOTPOS SLASHPOS) 1)))
  286.             (setq BASEPATH (substr AVW_FNAME 1 SLASHPOS))
  287.         )
  288.     )
  289.     
  290. ;;Traverse the basename string looking to see if it's a long filename with spaces
  291. ;;Replace the spaces with underscores "_" only for the pupose of naming the block
  292. ;;The block is not allowed to have spaces in it. Original filename and basename are not
  293. ;;altered.
  294.  
  295.     (setq BASENAMELEN (strlen BASENAME))
  296.     (setq UNDERBAR "_")
  297.     (setq COUNTER BASENAMELEN)
  298.     (setq bDONE 0)
  299.     (setq bSPACE 0)
  300.     (setq BASENAMEL BASENAME)    
  301.     (while (= bDONE 0)
  302.         (if (=(substr BASENAMEL COUNTER 1) " ")
  303.             (progn                    
  304.                 (setq SPACEPOS COUNTER)        
  305.                 (setq MINUSSPACE (- SPACEPOS 1))
  306.                 (setq PLUSSPACE (+ SPACEPOS 1))
  307.                 (setq BASENAMEL (strcat (strcat (substr BASENAMEL 1 MINUSSPACE) "_")(substr BASENAMEL PLUSSPACE BASENAMELEN)))
  308.                 (setq bSPACE 1)
  309.                 (if(= bSPACE 1)
  310.                     (progn
  311.                         (setq BASENAMEL (strcat (strcat (substr BASENAMEL 1 MINUSSPACE) "_")(substr BASENAMEL PLUSSPACE BASENAMELEN)))
  312.                     )
  313.                 )                
  314.             )
  315.         )
  316.  
  317.         (setq COUNTER (- COUNTER 1))
  318.         
  319.         (if (<= COUNTER 0)
  320.             (progn
  321.                 (setq bDONE 1)
  322.             )
  323.         )
  324.     )
  325.  
  326.     (if(= bSPACE 1)
  327.         (progn
  328.             (setq BASENAME BASENAMEL)
  329.         )
  330.     )
  331.  
  332. ;;Need to alter the BLOCKNAME if the combined layer name
  333. ;;will exceed 31 characters. Combined name includes 
  334. ;;BLOCKNAME+_PS|ADMEREDLINE. Rename BASENAME to BLOCKNAME
  335. ;;since that's what is really is.
  336.  
  337.     (setq BLOCKNAME BASENAME)
  338.     (setq TEMPBLKNAME BLOCKNAME)    
  339.  
  340.     ;;Check the length of the BLOCKNAME. If it's still
  341.     ;;to long (ie..greater than 10 characters to be safe), take 
  342.     ;;the last 10 characters to make the BLOCKNAME
  343.     
  344.     (setq BLOCKLEN (strlen TEMPBLKNAME))    
  345.     (if(>= BLOCKLEN 10)
  346.         (progn
  347.             (setq STARTPOS (- BLOCKLEN 10))
  348.             (setq TEMPBLKNAME2 TEMPBLKNAME)
  349.             (setq TEMPBLKNAME (substr TEMPBLKNAME2 STARTPOS BLOCKLEN))
  350.         )
  351.     )
  352.  
  353.     (setq BLOCKNAME TEMPBLKNAME)
  354.             
  355. ;;Now it's time to try to attach the Xref
  356.  
  357.     (if (= AVW_FNAME nil)
  358.         (prompt "\nFunction failed due to incorrect name")
  359.         (progn
  360.             (command "layer" "new" "ADMEREDLINE" "set" "ADMEREDLINE" "")
  361.             (setq INITIALTILEMODE (getvar "TILEMODE"))
  362.             (if (= INITIALTILEMODE 1)
  363.                 (progn
  364.                     (c:insertmspaceredline)
  365.                     (c:insertpspaceredline)
  366.                     (command "tilemode" "1")
  367.                 )
  368.  
  369.             ;; else
  370.                 (progn
  371.                     (c:insertpspaceredline)
  372.                     (c:insertmspaceredline)
  373.                     (command "tilemode" "0")
  374.                 )
  375.  
  376.             )
  377.             (c:changeblockname)
  378.             (command "layer" "lock" "ADMEREDLINE" "")
  379.             (setq LAYERCREATED 1)
  380.         )
  381.     )
  382.  
  383.     (setvar "CLAYER" ORIGLAYER)
  384.     (setq NOTE 0)
  385.     (setq LINK 0)
  386.     (princ)
  387. )
  388.  
  389. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  390. ;;INSERT REDLINE XREF IN MSPACE
  391.  
  392. (defun c:insertmspaceredline()
  393.  
  394.     ;;Get the AutoCAD Environment Variable and save it to a safe place
  395.     (setq TEMPENV1 (getenv "ACAD"))
  396.     
  397.     ;;Create a copy of the original ACAD Environment variable
  398.     (setq TEMPENV2 TEMPENV1)
  399.  
  400.     ;;Add a semi-colon to the end of the Environment variable
  401.     ;;for path separation
  402.     (setq TEMPENV2 (strcat TEMPENV2 ";"))
  403.  
  404.     ;;Add BASEPATH to the Environment variable
  405.     (setq TEMPENV2 (strcat TEMPENV2 BASEPATH))
  406.     (setq TEMPENV2 (strcat TEMPENV2 ";"))
  407.     
  408.     ;;Save the new ACAD Environment variable
  409.     (setenv "ACAD" TEMPENV2)
  410.     
  411.     ;;Set the Block name
  412.     (strcase BLOCKNAME)
  413.     (setq MSPACENAME (strcat BLOCKNAME "="))    
  414.     (setq MSPACENAME (strcat MSPACENAME AVW_FNAME))
  415.     (command "tilemode" "1")
  416.     (command "xref" "attach" MSPACENAME "0,0" "" "" "")
  417.  
  418.     ;;Modelspace redline is now attached
  419.     (setq AVW_REDATTACHED "TRUE")
  420.  
  421.     ;;Reset the AutoCAD Environment Variable to its original state
  422.     (setenv "ACAD" TEMPENV1)
  423.  
  424. )
  425.  
  426. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  427. ;;INSERT REDLINE XREF IN PSPACE
  428.  
  429. (defun c:insertpspaceredline()
  430.  
  431.     ;;Get the AutoCAD Environment Variable and save it to a safe place
  432.     (setq TEMPENV1 (getenv "ACAD"))
  433.     
  434.     ;;Create a copy of the original ACAD Environment variable
  435.     (setq TEMPENV2 TEMPENV1)
  436.  
  437.     ;;Add a semi-colon to the end of the Environment variable
  438.     ;;for path separation
  439.     (setq TEMPENV2 (strcat TEMPENV2 ";"))
  440.  
  441.     ;;Add BASEPATH to the Environment variable
  442.     (setq TEMPENV2 (strcat TEMPENV2 BASEPATH))
  443.     (setq TEMPENV2 (strcat TEMPENV2 ";"))
  444.     
  445.     ;;Save the new ACAD Environment variable
  446.     (setenv "ACAD" TEMPENV2)
  447.  
  448.     ;;Set the Block name
  449.     (strcase BLOCKNAME)
  450.     (setq PSPACENAME (strcat BLOCKNAME "_ps="))
  451.     (setq PSPACENAME (strcat PSPACENAME AVW_FNAME))
  452.     (command "tilemode" "0")
  453.     (command "xref" "attach"  PSPACENAME "0,0" "" "" "")
  454.     (command "layer" "freeze" (strcat BLOCKNAME "_PS|*") "")
  455.     (command "layer" "thaw" (strcat BLOCKNAME "_PS|__AVIEW__") "")
  456.  
  457.     ;;Need to turn on the redline_pspace layers
  458.     (command "layer" "thaw" (strcat BLOCKNAME "_PS|REDLINE_PSPACE") "")
  459.  
  460.     ;;Need to enable VISRETAIN, since we are freezing/thawing specific xref layers. If user saves base dwg, with redlines
  461.     ;; xref'ed, the layer settings will be saved only if VISRETAIN=1
  462.     (command "visretain" "1")
  463.  
  464.     ;;Paperspace redline is now attached
  465.     (setq AVW_REDATTACHED "TRUE")
  466.  
  467.     ;;Reset the AutoCAD Environment Variable to its original state
  468.     (setenv "ACAD" TEMPENV1)
  469. )
  470.  
  471. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  472. ;;CHANGE THE BLOCK NAME
  473.  
  474. (defun c:changeblockname()
  475.  
  476. ;;This function is to alter the block name of the attached xref to strip
  477. ;;out the .dwg on the end of the filename so that after saving, the xref
  478. ;;will be resolved when the drawing is reloaded.
  479.     
  480.  
  481.     (setq NEWBLOCKNAME (tblobjname "BLOCK" BLOCKNAME))
  482.     (setq RETURN (chgpath NEWBLOCKNAME))
  483.     (if (= RETURN 0)
  484.         (progn
  485.             (princ "\n")
  486.             (princ "Unable to sucessfully complete block name change. \n")
  487.             (princ "You may be unable to save redlines. \n")
  488.             (princ "Please contact technical support.")
  489.             (princ "\n")
  490.         )
  491.     )
  492. )
  493. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  494. ;;HIDE MODELSPACE REDLINES
  495.  
  496. (defun c:hidemspaceredlines()
  497.     (if (= AVW_REDATTACHED "TRUE")
  498.         (progn
  499.             (setq CURRENTTILEMODE (getvar "TILEMODE"))
  500.             (if (= CURRENTTILEMODE 0)
  501.                 (progn
  502.                     (initget "Yes No")
  503.                     (setq ANSWER (getkword "This command hides Modelspace redlines in viewports (in Tilemode 0). Continue? (Yes or No)  "))
  504.                     (princ ANSWER)
  505.                     (if (= ANSWER "Yes")
  506.                         (progn
  507.                             (command "pspace")
  508.                             (command "vplayer" "freeze" "ADMEREDLINE" "all" "thaw" "ADMEREDLINE" "current")
  509.                             (command)
  510.                         )
  511.  
  512.                         (progn
  513.                             (command)
  514.                         )        
  515.                     )
  516.                 )
  517.                 ;ELSE
  518.                 (progn
  519.                     (princ "\nThis feature works in paperspace only.")
  520.                     (princ)                    
  521.                 )
  522.             )
  523.         )
  524.         ;;Else post a message on the command line if there are no redlines
  525.         ;;currently attached.
  526.         (progn
  527.             (princ "\nThere are no redlines currently attached.")
  528.             (princ)
  529.         )
  530.     )
  531. )
  532.  
  533. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  534. ;;REMOVE REDLINE FUNCTION
  535.  
  536. (defun c:aviewremoveredline()
  537.     (if (= AVW_REDATTACHED "TRUE")
  538.         (progn
  539.             (command "layer" "unlock" "ADMEREDLINE" "")
  540.             (setq SSREDLINE (ssget "X" '(( 8 . "ADMEREDLINE"))))
  541.             (setq NUMREDLINES (sslength SSREDLINE))
  542.             (setq COUNT 0)
  543.  
  544.             (while (< COUNT NUMREDLINES)
  545.                 (progn
  546.                     (setq XREFENT (entget (ssname SSREDLINE COUNT)))
  547.                     (setq XNAME (dxf 2 XREFENT))
  548.                     (command "_xref"  "detach"  XNAME)
  549.                     (setq JUNK (+ 1 COUNT))
  550.                     (setq COUNT JUNK)
  551.                 )
  552.             )
  553.             (setq AVW_REDATTACHED "FALSE")
  554.         )
  555.         ;;Else post a message on the command line if there are no redlines
  556.         ;;currently attached.
  557.         (progn
  558.             (princ "\nThere are no redlines currently attached.")
  559.             (princ)
  560.         )
  561.     )
  562. )
  563.  
  564. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  565. ;;LOAD AVIEW FROM ACAD FUNCTION
  566.  
  567. (defun c:aviewload()
  568.     
  569.     (setq dwgfilename (getvar "dwgname"))
  570.     (setq dwgpathname (getvar "dwgprefix"))
  571.     (setq dwgfilename (strcat dwgpathname dwgfilename))
  572.     (setq len (strlen dwgfilename))
  573.     (startapp "viewopen.exe" dwgfilename)
  574. )
  575.  
  576. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  577. ;;LIST REDLINES FUNCTION
  578.  
  579. (defun c:aviewlistredlines()
  580.     (if (= AVW_REDATTACHED "TRUE")
  581.         (progn
  582.             (command "layer" "unlock" "ADMEREDLINE" "")
  583.             (setq SSRED (ssget "X" '(( 8 . "ADMEREDLINE"))))
  584.             (setq NUMRED (sslength SSRED))
  585.             (setq COUNT 0)
  586.             (princ "\nThere are ")
  587.             (princ NUMRED)
  588.             (princ " redline files open. ")
  589.             (princ "The redline files are: ")
  590.             (while (< COUNT NUMRED)
  591.                 (progn
  592.                     (setq XREFENTITY (entget (ssname SSRED COUNT)))
  593.                     (setq XREFENTNAME (dxf 2 XREFENTITY))
  594.                     (setq JUNK (+ 1 COUNT))
  595.                     (setq COUNT JUNK)
  596.                     (princ "\n")
  597.                     (princ XREFENTNAME)            
  598.                 )
  599.             )
  600.         )
  601.         ;;Else post a message on the command line if there are no redlines
  602.         ;;currently attached.
  603.         (progn
  604.             (princ "\nThere are no redlines currently attached.")
  605.             (princ)
  606.         )
  607.     )    
  608. )
  609.  
  610. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  611. ;;ADD REDLINE MENU FUNCTION
  612.  
  613. (defun c:aviewaddtomenu()
  614.  
  615.     ;;Load the menus and toolbars if this is a windows environment    
  616.     (if (wcmatch (getvar "platform") "*Windows*")
  617.         (progn
  618.             
  619.             (command "menuload" "aviewred")
  620.             (menucmd "P6=+aviewredline.pop1")
  621.             (setq LAYERCREATED 0)
  622.             (command)
  623.             (princ "\n")
  624.         )
  625.       )
  626.  
  627.     ;;Load any ARX applications to be used
  628.     (command "arx" "l" "chgblockpath")
  629. )
  630.  
  631. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  632. ;;LOAD MENU
  633.  
  634. (if S::STARTUP 
  635.  
  636.     (setq s::startup (append s::startup '((c:aviewaddtomenu)) ))
  637.     (defun s::startup ( ) (c:aviewaddtomenu))
  638.  
  639. )
  640.  
  641. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  642. ;;DISPLAY THE REDLINE TOOLBAR
  643.  
  644. (defun c:aviewdisplaytoolbar()
  645.     (command "_toolbar" "Redline Toolbar" "show")
  646. )
  647.  
  648. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  649. ;;HANDLE ANY ERRORS
  650.  
  651. (defun *error*(msg)
  652.  
  653.     (princ "An error has occurred. Please re-install the Autodesk View")
  654.     (princ "\n")
  655.     (princ "Redlining Import Tool or contact Autodesk Technical Support for")
  656.     (princ "\n")
  657.     (princ "further information.")
  658.     (princ "\n")
  659. )