Author Topic: Draw Line/Text tool ?  (Read 968 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Draw Line/Text tool ?
« on: January 22, 2021, 04:49:21 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun C:TEST7 ()
  2.  
  3. (defun saveVars()
  4.   (setq radios(get_tile "radios"))
  5.   (setq saveSet(atoi(get_tile "saveset")))              ;;;--- See if the user wants to save the settings
  6.   (setq sStr(get_tile "layerlist"))                     ;;;--- Get the selected item from the layer list
  7.  
  8. (if(/= sStr "")                                         ;;;--- If the index of the selected item is not "" then something was selected
  9.     (progn
  10.       (setq sIndex(atoi sStr))                          ;;;--- Something is selected, so convert from string to integer
  11.       (setq layerName(nth sIndex layerList))            ;;;--- And get the selected item from the list
  12.          )
  13.                                                         ;;;--- Else, nothing is selected
  14.     (progn
  15.       (setq sIndex -1)                                  ;;;--- Set the index number to -1
  16.       (setq layerName nil)                              ;;;--- And set the name of the selected item to nil
  17.      )
  18.    )
  19.  
  20.   (setq sStr1(get_tile "Stylelist"))                    ;;;--- Get the selected item from the text list
  21.  (if(/= sStr1 "")                                       ;;;--- If the index of the selected item is not "" then something was selected
  22.    (progn
  23.       (setq sIndex1(atoi sStr1))                        ;;;--- Something is selected, so convert from string to integer
  24.       (setq StyleName(nth sIndex1 StyleList))           ;;;--- And get the selected item from the list
  25. )
  26.     ;;;--- Else, nothing is selected
  27.     (progn
  28.       (setq sIndex1 -1)                                 ;;;--- Set the index number to -1
  29.       (setq styleName nil)                              ;;;--- And set the name of the selected item to nil
  30.      )
  31.    )
  32.  )
  33.  
  34. ;;;  ;;;--- Get the selected item from the text list
  35. ;;;  (setq sStr2(get_tile "LineTypeList"))
  36. ;;;
  37. ;;;
  38. ;;;  ;;;--- If the index of the selected item is not "" then something was selected
  39. ;;;  (if(/= sStr2 "")
  40. ;;;
  41. ;;;      (progn
  42. ;;;
  43. ;;;      ;;;--- Something is selected, so convert from string to integer
  44. ;;;      (setq sIndex2(atoi sStr2))
  45. ;;;
  46. ;;;      ;;;--- And get the selected item from the list
  47. ;;;      (setq LineTypeName(nth sIndex LineTypeList))
  48. ;;;)
  49. ;;;    ;;;--- Else, nothing is selected
  50. ;;;    (progn
  51. ;;;
  52. ;;;      ;;;--- Set the index number to -1
  53. ;;;      (setq sIndex2 -1)
  54. ;;;
  55. ;;;  
  56. ;;;      ;;;--- And set the name of the selected item to nil
  57. ;;;      (setq LineTypeName nil)
  58. ;;;     )
  59. ;;;   )
  60. ;;; )
  61.  
  62.  ;;(if (tblsearch "style")
  63.   (setq stylename "textstyle")
  64.   (setq LineTypeName "Celtype")
  65.   ;;)
  66.  
  67.   ;;;--- Main application
  68.  
  69.   ;;;--- Load the dcl file from disk into memory
  70.   (setq dcl_id (load_dialog "TEST7.dcl"))
  71.    
  72.  
  73.     ;;;--- Else, the DCL file was loaded
  74.     ;;(progn
  75.  
  76.       ;;;--- Load the definition inside the DCL file
  77.       (if (not (new_dialog "TEST7" dcl_id))
  78.         (progn
  79.           (alert "The TEST7 definition was not found.")
  80.           (exit)
  81.         )
  82.        )
  83.      
  84.         ;;;--- Else, the definition was loaded
  85.         (progn
  86.           (setq layerList(list "0" "LINE1" "LINE2" "LINE3" "LINE4" "LINE5"))
  87.           (setq StyleList(list "L080" "L100" "L120" "L140" "L175" "L200"))
  88.           (setq LineTypeList(list "Continuous" "Dashed" "Dashed2" "Voltage" "ZigZag"))
  89.          
  90.  
  91.           ;;;--- Add the layer names to the dialog box
  92.           (start_list "layerlist" 3)
  93.           (mapcar 'add_list layerList)
  94.           (end_list)
  95.  
  96.           (start_list "Stylelist" 3)
  97.           (mapcar 'add_list styleList)
  98.           (end_list)
  99.  
  100.            (start_list "LineTypelist" 3)
  101.           (mapcar 'add_list LineTypeList)
  102.           (end_list)
  103.  
  104.            ;;;--- Add the code here to check for defaults
  105.           (if(/= (getvar "USERS1") "")
  106.             (progn
  107.               (setq radios (getvar "users1"))
  108.               (setq saveSet(getvar "users2"))
  109.               (setq layerIndex(getvar "users3"))
  110.               (setq StyleIndex(getvar "users4"));;
  111.               (set_tile "radios" radios)
  112.               (set_tile "saveset" saveSet)
  113.               (set_tile "layerlist" layerIndex)
  114.               (set_tile "Stylelist" StyleIndex);;
  115.               (set_tile "LineTypeList" LineIndex)
  116.             )
  117.            )
  118.  
  119.           ;;;--- If an action event occurs, do this function
  120.           (action_tile "line" "(setq action $value)")
  121.           (action_tile "text" "(setq action $value)")
  122.           (action_tile "layerlist" "(setq action $value)");;
  123.           (action_tile "stylelist" "(setq action $value)")
  124.           (action_tile "LineTypelist" "(setq action $value)")
  125.           (action_tile "cancel" "(done_dialog 1)")
  126.           (action_tile "accept" "(saveVars)(done_dialog 2)")
  127.  
  128.           ;;;--- Display the dialog box
  129.           (setq ddiag(start_dialog))
  130.  
  131.           ;;;--- Unload the dialog box
  132.           (unload_dialog dcl_id)
  133.  
  134.           ;;;--- If the cancel button was pressed - display message
  135.           (if (= ddiag 1)
  136.             (princ "\n \n ...SAMPLE7 Cancelled. \n ")
  137.           )
  138.  
  139.           ;;;--- If the "Okay" button was pressed
  140.           (if (= ddiag 2)
  141.  
  142.             (progn
  143.               (if(= radios "line")
  144.                 (progn
  145.                 (setvar 'cecolor (rtos (acad_colordlg 256) 2 0))
  146.                 (setvar "clayer" layerName)
  147.                 (setvar "Celtype" LineTypeName)
  148.                 (command "line")
  149.                 )
  150.                )
  151.  
  152.                        
  153.              (if(= radios "text")
  154.                 ;;(setvar 'textstyle "stylename")
  155.                (progn
  156.                (setvar 'cecolor (rtos (acad_colordlg 256) 2 0))
  157.                (setvar "clayer" layerName)              ;;this is not working......................
  158.                (command "text" "s" stylename)
  159.                )
  160.              )
  161.  
  162.               ;;;--- See if we need to save the settings
  163.               (if(= saveSet 1)
  164.                 (progn
  165.  
  166.                   ;;;--- Add code here to save the settings as defaults
  167.                   (setvar "USERS1" radios)
  168.                   (setvar "USERS2" (itoa saveSet))
  169.                   (setvar "USERS3" sSTR)
  170.                                          )
  171.               )
  172.             )
  173.           )
  174.         )
  175.  
  176.   ;;;--- Suppress the last echo for a clean exit
  177.   (princ)
  178.  
  179. )
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10