Author Topic: Routine runs straight through but not complete.  (Read 935 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Routine runs straight through but not complete.
« on: April 20, 2023, 11:42:02 AM »
If I separate ----Test TBs----- from the ---dcl--- & ----Scale TBs------- all works fine in two separate routines. Combining them doesn't seem to work. Debugging isn't showing me anything at all. The routine goes through (for the most part) the entire routine.

I've experienced this before with combining routines and the same thing happened, so I'm assuming I'm missing a piece of the puzzle.

Code - Auto/Visual Lisp: [Select]
  1.  
  2.  
  3. (defun c:spacex (/ ss attvalue dimsc blk1 fld1 siz names dsty dstydata userclick x obj obj1 obj2
  4.                        olay ss ss1 ss2 tag1 tag2 att )
  5.   (defun *error* (msg)
  6.     (if osm
  7.       (setvar 'osmode osm)
  8.     )
  9.     (if (not (member msg '("Function cancelled" "quit / exit abort")))
  10.       (princ (strcat "\nError: " msg))
  11.     )
  12.     (princ)
  13.   )
  14.   (setq osm (getvar 'osmode))
  15.   (setvar 'osmode 0)
  16.   (setvar 'cmdecho 0)
  17.  
  18.     (defun lm:getattributevalue (blk tag / val enx)
  19.     (while
  20.       (and (null val)
  21.            (= "ATTRIB"
  22.               (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))
  23.            )
  24.       )
  25.       (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
  26.         (setq val (cdr (assoc 1 enx)))
  27.       )
  28.     )
  29.   )
  30.  
  31. ;;------------------test and insert TBs---------------------------  
  32.  
  33.   (setq ss (ssget "x" '((0 . "INSERT") (2 . "ATTSubCode") (66 . 1))))
  34.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "HIDDEN_SUBJCODE"))
  35.   (setq dimsc (getvar 'dimscale))
  36.   (cond
  37.    ((wcmatch (strcase attvalue)
  38.               "03,05,84,60,62,64,80,66,67,68,72,70,71,73,74,86,88,89,82,83,90,92,93,94,96,98,41,42,43,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59"
  39.    )
  40.    
  41.     (command-s "layout" "t" "TBLK_BORD_STR_STD" "ANSI-D 22x34")
  42.     (command "Clayout" "ANSI-D 22x34")
  43.     (command "_.-insert" "STA_STR_STANDARDS" "0,0" dimsc dimsc "0")
  44.     (command "-layer" "filter" "s" "All" "")
  45.     (command "zoom" "all")
  46.     )
  47.  
  48.   ((wcmatch (strcase attvalue)
  49.               "05,01,10,14,16,40,12,29,20,22,30,34,32,35,41,42,56,44,46,48,49,50,52,67"
  50.    )
  51.     (command "Clayout" "Model")
  52.     (command "_.-insert" "BLANK" "0,0" dimsc dimsc "0")
  53.     (command "explode" "last")
  54.     ;;(command "._layer" "unlock" "TTBK_BORD_LINES" "")
  55.     ;;(command "._layer" "Make" "LINE1" "C" "YELLOW" "LINE1" "")
  56.     (command "Zoom" "Extents")
  57.   )
  58.  )
  59.  
  60. ;;-----------------dcl------------------
  61.  
  62.  (setq SIZ "0")
  63.   (setq NAMES '("NONE" "1/4\" = 1'-0\"" "1/2\" = 1'-0\"" "1\" = 1'-0\""
  64.                 "1-1/2\" = 1'-0\"" "3\" = 1'-0\"" "6\" = 1'-0\""
  65.                )
  66.   )
  67.  
  68.   (setq dcl_id (load_dialog "STA_Scale_TB.dcl")) ;load dialog
  69.  
  70.   (if (not (new_dialog "STA_Scale_TB" dcl_id))  ;test for dialog
  71.     (exit) ;exit if no dialog
  72.   ) ;if
  73.  
  74.   (start_list "scales") ;start the list box
  75.   (mapcar 'add_list NAMES) ;fill the list box
  76.   (end_list) ;end list
  77.  
  78.     "cancel" ;if cancel button pressed
  79.     "(done_dialog) (setq userclick nil)" ;close dialog, set flag
  80.   ) ;action_tile
  81.  
  82.     "accept" ;if O.K. pressed
  83.     (strcat ;string 'em together
  84.             "(progn
  85.        (setq SIZ (get_tile \"scales\")))"
  86.             ;get list selection
  87.             "(done_dialog)(setq userclick T))" ;close dialog, set flag
  88.     ) ;strcat
  89.   ) ;action tile
  90.  
  91.   (start_dialog) ;start dialog
  92.  
  93.   (unload_dialog dcl_id) ;unload
  94.  
  95.   (if userclick  ;check O.K. was selected
  96.     (progn
  97.       (cond
  98.         ((= SIZ "0") (setvar "dimscale" 1))
  99.         ;;FULL
  100.         ((= SIZ "1") (setvar "dimscale" 48))
  101.         ;;1/4"
  102.         ((= SIZ "2") (setvar "dimscale" 24))
  103.         ;;1/2"
  104.         ((= SIZ "3") (setvar "dimscale" 12))
  105.         ;;1"
  106.         ((= SIZ "4") (setvar "dimscale" 8))
  107.         ;;1 1/2"
  108.         ((= SIZ "5") (setvar "dimscale" 4))
  109.         ;;3"
  110.         ((= SIZ "6") (setvar "dimscale" 2))
  111.         ;;6"
  112.       ) ;cond
  113.  
  114.  
  115.     (setq tag1 "DRAWINGSCALE")
  116.       (setq ss (ssget "x" '((2 . "TBLK_ATT_STA") (66 . 1))))
  117.       (repeat (setq x (sslength ss))
  118.         (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1)))))
  119.         (if (= (vla-get-hasattributes obj) :vlax-true)
  120.           (foreach att (vlax-invoke obj 'getattributes)
  121.             (if (= tag1 (strcase (vla-get-tagstring att)))
  122.               (vla-put-textstring att (nth (atoi siz) names))
  123.             )
  124.           )
  125.         )
  126.       )
  127.  
  128.    
  129.   (setq tag2 "DESIGNER")
  130.    (if (setq ss1 (ssget "_X" '((0 . "INSERT") (2 . "TBLK_ATT_STA") (66 . 1))))
  131.     (repeat (setq idx (sslength ss1))
  132.         (setq idx (1- idx)
  133.               obj (vlax-ename->vla-object (ssname ss1 idx))
  134.         )
  135.         (vl-some
  136.            '(lambda ( att )
  137.                 (if (and (= tag2 (strcase (vla-get-tagstring att))) (vlax-write-enabled-p att))
  138.                     (not (vla-put-textstring att (strcase (substr (getvar 'loginname) 1 3))))
  139.                 )
  140.             )
  141.             (vlax-invoke obj 'getattributes)
  142.         )
  143.     )
  144. )
  145.  
  146. ;;--------------------Scale TBs------------------------
  147.  
  148.      (setq dimsc (getvar 'dimscale))
  149.         (command "-layer" "unlock" "TTBK_BORD_LINES" "")
  150.  
  151.       (setq blk1 (ssget "x" '((2 . "TBLK_BORD_CTL,TBLK_BORD_MAX,TBLK_ATT_STA"))))  ;;TBLK_BORD_CTL
  152.         (command "scale" blk1 "" "0,0" dimsc)
  153.      
  154.      
  155.       (setq fld1 (ssget "x" '((8 . "TTBK_TBLK_VAULTNO"))))  ;;Vault number field.
  156.         (command "scale" fld1 "" "0,0" dimsc)
  157.      
  158.       ;;(command "-layer" "lock" "TTBK_BORD_LINES" "")
  159.  
  160.       (setvar "fielddisplay" 0)
  161.  
  162.       (if (= (tblsearch "layer" "TTBK_TBLK_REVINIT"))
  163.         (command "-Layer" "Make" "TTBK_TBLK_REVINIT" "c" "green" "TTBK_TBLK_REVINIT" "")
  164.       )
  165.      
  166.       (setq Odyn (getvar 'dynmode))
  167.       (setvar 'dynmode 0)
  168.      
  169.       (while (setq dsty (tblnext "dimstyle" (not dsty)))
  170.         (setq dstydata (entget
  171.                          (tblobjname "dimstyle" (cdr (assoc 2 dsty)))
  172.                        )
  173.         )
  174.         (if (assoc 40 dstydata)  ; [because not included in data if default 1.0]
  175.           (entmod
  176.             (subst (cons 40 dimsc) (assoc 40 dstydata) dstydata)
  177.           )
  178.           ; then -- replace it
  179.           (entmod (append dstydata (list (cons 40 dimsc))))
  180.           ; else -- add it
  181.         )
  182.       )
  183.  
  184.       (command "layer" "M" "LINE1" "C" "YELLOW" "LINE1" "")
  185.       (command "limits" (getvar "extmin") (getvar "extmax"))
  186.       (command "zoom" "e")
  187.  
  188.  
  189.       (setvar "CMDECHO" 0)
  190.       (setvar "BLIPMODE" 0)
  191.  
  192.       (command ".style" "Standard" "ipco.shx" (* 1.000 dimsc) "0.85" "0" "n" "n" "n")
  193.       (command ".style" "L080" "ipco.shx" (* 0.0781 dimsc) "0.85" "0" "n" "n" "n")
  194.       (command ".style" "L100" "ipco.shx" (* 0.0938 dimsc) "0.85" "0" "n" "n" "n")
  195.       (command ".style" "L120" "ipco.shx" (* 0.1094 dimsc) "0.85" "0" "n" "n" "n")
  196.       (command ".style" "L140" "ipco.shx" (* 0.1406 dimsc) "0.85" "0" "n" "n" "n")
  197.       (command ".style" "L175" "ipco.shx" (* 0.1563 dimsc) "0.85" "0" "n" "n" "n")
  198.       (command ".style" "L200" "ipco.shx" (* 0.1719 dimsc) "0.85" "0" "n" "n" "n")
  199.       (command ".style" "L240" "ipco.shx" (* 0.2187 dimsc) "0.85" "0" "n" "n" "n")
  200.    
  201.       (command ".style" "Ls080" "ipco.shx" (* 0.0781 dimsc) "0.85" "0" "n" "n" "n")
  202.       (command ".style" "Ls100" "ipco.shx" (* 0.0938 dimsc) "0.85" "0" "n" "n" "n")
  203.       (command ".style" "Ls120" "ipco.shx" (* 0.1094 dimsc) "0.85" "0" "n" "n" "n")
  204.       (command ".style" "Ls140" "ipco.shx" (* 0.1406 dimsc) "0.85" "0" "n" "n" "n")
  205.       (command ".style" "Ls175" "ipco.shx" (* 0.1563 dimsc) "0.85" "0" "n" "n" "n")
  206.       (command ".style" "Ls200" "ipco.shx" (* 0.1719 dimsc) "0.85" "0" "n" "n" "n")
  207.       (command ".style" "Ls240" "ipco.shx" (* 0.2187 dimsc) "0.85" "0" "n" "n" "n")
  208.      
  209.     ) ;progn
  210.    )
  211.    
  212.       (setvar "cmdecho" 1)
  213.       (setvar "dynmode" Odyn)
  214.       (command "_zoom" "e")
  215.      
  216.       (alert "Way to go!!! You scaled the border.")
  217.  
  218.    (princ)
  219. )

The theory is...
We have a 3rd party drawing vault where a properties card is filled out with a subject code for each drawing type. This routine would look at the subject code in the TB attribute and insert the correct title block. If the subject code is a model space code the dcl fires and asks the user for a scale (I know...why don't you use paper space?!?!? If you feel the need to discuss that, please move on.) I get the dcl to pop up and the dimscale is properly set from that selection, the line1 layer is set current but nothin else in that section is working.
J. Logan
ACAD 2018

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

jlogan02

  • Bull Frog
  • Posts: 327
Re: Routine runs straight through but not complete.
« Reply #1 on: April 20, 2023, 11:57:36 AM »
forgot to attach the dcl. Sadly, I can't attach company drawings.
J. Logan
ACAD 2018

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

BIGAL

  • Swamp Rat
  • Posts: 1434
  • 40 + years of using Autocad
Re: Routine runs straight through but not complete.
« Reply #2 on: April 22, 2023, 08:07:35 PM »
A couple of suggestions, use a dwg template with your layouts all setup with different sizes, I dont understand why your scaling your title block, we never did that, that is what Mview is for set a scale for the view of the model objects

Re your dcl you can use this in future it only requires like 2 lines of code to make a dcl and get an answer. Look at examples in start of code, you get a string as answer form pick or for multiple choices look at the value of "but" and compare to a list.

By using a dwt all your layers are set and all your styles exist. We would get a dwg from a external source and just paste into our template so everything was there.



« Last Edit: April 22, 2023, 08:11:04 PM by BIGAL »
A man who never made a mistake never made anything