Jump to content

Need help extracting attribute values in Lisp


Recommended Posts

Posted

Hello all,

 

I am currently working on a Lisp that I need some help with. Here's the situation, I have 3 different templates from a client that are for different drawing sizes. Each one of which has a different drawing border (attributed block) in paper space based on each size. What I want to do is make decisions in my Lisp based on which drawing template is used. The best way that I figured out to do this by "figuring out" which title block is in the drawing. To do so, I came up with either listing the blocks int he drawing or by listing the values of attribute. However, I have not been able to find anywhere how to find this information so that I can decide based on it. Any suggestions would be greatly appreciated.

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • Archiman86

    16

  • Lee Mac

    15

Posted

This should retrieve a List of all attributed inserts in the drawing:

 

(defun c:blklist (/ ss i bname bnameLst)
 (if (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 66 1)
               (if (getvar "CTAB")
                 (cons 410 (getvar "CTAB"))
                 (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
   (setq i (sslength ss))
   (while (not (minusp (setq i (1- i))))
     (setq bname (cdr (assoc 2 (entget (ssname ss i))))
       bnameLst (cons bname bnameLst))))
   (princ "\n<!> No Attributed Blocks Found. <!>"))
 (princ))

 

(untested and written quickly!)

Posted

This should work, I appreciate it. Is there any way to extract values from attributes. Say there is an attribute in the title block that designates whether it is a "D" size, "E" size or "A" size drawing. Where the attribute tag is "Size" and the value in the title block is "D", "E" or "A" respectively. Is there a way to extract that value in order to decide sizes, scales, and so forth based on that.

Posted

This will produce an associative list of all blocks with attribute value of Size:

 

(defun c:AttLst (/ ss eLst bEnt aEnt aEntLst aVal blkLst)
 (vl-load-com)
 (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 66 1)
               (if (getvar "CTAB")
                 (cons 410 (getvar "CTAB"))
                 (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
     (foreach e eLst
   (setq bEnt (cdr (assoc 2 (entget e)))
         aEnt (entnext e))
   (while (= "ATTRIB" (cdr (assoc 0 (setq aEntLst (entget aEnt)))))
     (if (= (cdr (assoc 2 aEntLst)) "SIZE")
       (progn
         (setq aVal (cdr (assoc 1 aEntLst))
           blkLst (cons (cons bEnt aVal) blkLst))))
     (setq aEnt (entnext aEnt)))))
   (princ "\n<!> No Attributed Blocks Found <!>"))
 (alert (vl-princ-to-string blkLst))
 (princ))

Posted

That works great! Thanks again. If you get bored one day, and you wouldn't mind helping out, I would greatly appreciate an explanation of how exactly that works. I mean, its good and all to complete the task that I am trying to complete, but for future reference, so that I understand it, and so that I can learn as well.

Posted

If you didnt mind. I am kind of new to AutoLisp. I understand the general idea on how it works, but going through the whole thing would be very beneficial.

 

Thanks in advance.

Posted

No Probs, I'm happy to help anyone wanting to better understand LISP:

 

(defun c:AttLst    (/ ss eLst bEnt aEnt aEntLst aVal blkLst) ; [b][color=Red]Define the function, localise the variables[/color][/b]
 
 (vl-load-com) ; [b][color=Red]Load the Visual LISP console [i](allows vl-... commands)[/i][/color][/b]
 
 (if ; [b][color=Red]If there exists a selection set such that:[/color][/b]
   (setq ss (ssget "X" ; [b][color=Red][i]"X" [/i]meaning search [i]entire database[/i] for entities with:[/color][/b]
             (list (cons 0 "INSERT") ; [b][color=Red]type: INSERT [i](Blocks, XRefs)[/i][/color][/b]
               (cons 66 1) ; [b][color=Red]Attributed[/color][/b]
               (if    (getvar "CTAB") ; [b][color=Red]If there is a variable [i]"CTAB"[/i] (newer releases - determines Model Space/Paper Space[/color][/b]
                 (cons 410 (getvar "CTAB")) ; [b][color=Red]Then filter by the CTAB variable[/color][/b]
                 (cons 67 (- 1 (getvar "TILEMODE"))) ; [b][color=Red]Otherwise use TILEMODE variable to filter.[/color][/b]
               ) ; [b][color=Red]end if[/color][/b]
             ) ;[b][color=Red] end list [Filter List][/color][/b]
          ) ;[b][color=Red] end Selection set aquirement [ssget][/color][/b]
     ) ; [b][color=Red]end Variable Setting [selection set stored in variable "ss"][/color][/b]
   (progn ; [b][color=Red]Wrap the following code for use in the IF statement:[/color][/b]
     (setq eLst ; [b][color=Red]Store the following list of entity names to variable "eLst"[/color][/b]
        (vl-remove-if 'listp ; [b][color=Red]Remove from the list if the item is a List[/color][/b]
          (mapcar 'cadr ; [b][color=Red]Produce a list of entity names (and possible coord values) from[/color][/b]
              (ssnamex ss) ;[b][color=Red] Information provided by "ssnamex" about the Selection Set[/color][/b]
              ) ; [b][color=Red]end Mapcar[/color][/b]
          ) ;[b][color=Red] end vl-remove-if[/color][/b]
       ) ; [b][color=Red]end variable setting[/color][/b]
     (foreach e eLst ; [b][color=Red]For Each item (e) in the eLst (entity name list):[/color][/b]
   (setq bEnt (cdr (assoc 2 (entget e))) ; [b][color=Red]Retrieve the Block Name [store to "bEnt"][/color][/b]
         aEnt (entnext e) ; [b][color=Red]Retrieve the Attribute Entity Name [store to aEnt][/color][/b]
   ) ; [b][color=Red]end Variable setting[/color][/b]
   (while (= "ATTRIB" (cdr (assoc 0 (setq aEntLst (entget aEnt))))) ; [b][color=Red]While the Entity Type is "ATTRIB"[ute][/color][/b]
     (if (= (cdr (assoc 2 aEntLst)) "SIZE") ; [b][color=Red]If the ATTRIBute name is "SIZE"[/color][/b]
       (progn ; [b][color=Red]wrap the following for use with the IF[/color][/b]
         (setq aVal   (cdr (assoc 1 aEntLst)) ; [b][color=Red]Store the ATTRIBute value [to aVal][/color][/b]
           blkLst (cons
                (cons bEnt aVal) ; [b][color=Red]Create an Associative list (dotted pair) of Block Name and Att. Value.[/color][/b]
                blkLst) ; [b][color=Red]Connect this to the main list[/color][/b]
         ) ; [b][color=Red]End Variable Setting[/color][/b]
       ) ; [b][color=Red]end Progn (code wrapper)[/color][/b]
     ) ;[b] [color=Red]end IF[/color][/b]
     (setq aEnt (entnext aEnt)) ; [b][color=Red]Move onto next Attribute in Block[/color][/b]
   ) ; [b][color=Red]End While[/color][/b]
     ) ; [b][color=Red]End Foreach[/color][/b]
   ) ; [color=Red][b]End Progn[/b][/color]
   (princ "\n<!> No Attributed Blocks Found <!>") ;[b][color=Red] If No Selection Set, then No Attributed Blocks Found in Drawing.[/color][/b]
 ) ; [b][color=Red]End IF[/color][/b]
 (alert (vl-princ-to-string blkLst)) ;[b][color=Red] Convert the Associative List to a String and Alert it in a Dialog Box to view result.[/color][/b]
 (princ) ; [b][color=Red]Exit Cleanly[/color][color=Red] - [suppress last function return][/color][/b]
) ; [b][color=Red]End Function[/color][/b]

 

The above should help you understand the processes behind the program more clearly, I have formatted the code so that it is more legible and less compact and commented each line with an explanation.

 

Happy Reading!

 

Cheers

 

Lee

 

PS> If there is anything you would like explained further, do not hesitate to ask :thumbsup:

 

Hope this helps

Posted

Hey, thank you very much for doing that. I really appreciate it. Also, do you have any suggestions for resources (books, etc.) that are great references for learning AutoLisp in greater detail. I have a few very basic references, but I was wondering if you have any recommendations for further delving into this subject.

 

Thanks again in advance.

Posted

Obviously the Developers Guide in the ACAD Visual LISP Editor is a great reference (just type "vlide" at ACAD command prompt).

 

I would recommend:

AfraLISP

 

Jeffery Sanders

 

ABC's of AutoLISP

 

 

But I'm sure there are loads more resources.

 

These should get you going :thumbsup:

 

Cheers

 

Lee

Posted

Lee, how can i edit that Lisp that you wrote so that I can call out the aVal as a variable. For instance, i want to decide "if attribute value = 'D' then..." I have tried to just add a "if" function, and then set a variable based on that, but it does not seem to be working in my full Lisp. I know at the end it is taking the attribute value and adding it to a list, and combining with the block name. then going onto the next attribute/block. How would I go about maybe, searching the list for a specific value, or specifically "Border.D" etc., so that I can configure the following commands accordingly.

Posted

Hi Archiman,

 

If I were to keep the output the same, i.e. an associative list, then you could manipulate the list in many different ways:

 

so, for instance, to do something with a block with name "block1", something like:

 

(foreach x blkLst
 (if (= "block1" (car x))
[color=Navy]    ... Do something with result ...[/color]
   ) ; end if
 ) ; end foreach

Or, maybe with multiple conditions:

 

(foreach x blkLst
 (cond
   ((= "block1" (car x))
[color=Navy]    ... Do something with result ...[/color]
   ) ; end condition 1
   ((= "block2" (car x))
[color=Navy]    ... Do something with result ...[/color]
   ) ; end condition 2
   ((= "block3" (car x))
[color=Navy]    ... Do something with result ...[/color]
   ) ; end condition 3
   (T[color=Navy]
   ... Do something with result ...[/color]
   ) ; end last condition
 ) ; end cond
) ; end foreach

Or maybe to pull out different attribute values:

 

(foreach y blkLst
 (cond
   ((= "3" (cdr x))
[color=Navy]    ... Do something with result ...[/color]
   ) ; end condition 1
   ((= "4" (cdr x))
[color=Navy]    ... Do something with result ...[/color]
   ) ; end condition 2
   ((= "5" (cdr x))
[color=Navy]    ... Do something with result ...[/color]
   ) ; end condition 3
 ) ; end cond
) ; end foreach

Another method - not quite as elegant:

 

(setq i (length blkLst))
(while (not (minusp (setq i (1- i))))
 (setq item (nth i blkLst))
 (if (= "block1" (car item))[color=Navy]
   ... Do something with result ...[/color]
   ) ; end if
 ) ; end while

Or perhaps you just want a list of Block Names with Attribute "Size":

 

(mapcar 'car blkLst)

Or just the attributes themselves:

 

(mapcar 'cdr blkLst)

Hope this clarifies things further.

 

If you have any more queries, let me know :)

 

Cheers

 

Lee

Posted

Lee, I have another quick question. I have hit a snag in this lisp, and I dont know why it is not working. Basically, here is the problem I am having. After decisions are made, I am setting variables to number values, for instance (thanks for the help with this routine):

 

 
 (foreach y blkLst
   (cond
     ((= "A" (cdr x))
      (setq numThree 20))
     ((= "D" (cdr x))
      (setq numThree 40))
     ((= "E" (cdr x))
      (setq numThree 60))
     ((= "S" (cdr x))
      (setq numThree 20))
   )
 )

 

basically, I have three different number variables based on user selections, in order to figure out the exact configuration required (the number values are set up as to only allow one configuration per final sum). The problem I am having is when I try to add the three variables up. When it gets to this point:

 

 (setq numEq (+ numOne numTwo numThree))

 

i get the error in the command line:

 

 
"; error: bad argument type: numberp: nil"

 

When I animate the lisp in VisualLisp, it breaks right as it is trying to add the three variables. Any help would be greatly appreciated, or any suggestions on a better way to set this up. Basically I have three inputs that decide configuration: two from user selction in the dialog box, and one from the attributes within the drawing file. Based and all of the different combinations of these inputs, I need to set configurations accordingly. If you would like to look at the entire file, let me know.

 

Thanks in advance,

 

Dan

Posted

 
 (foreach[b][color=Red] y[/color][/b] blkLst
   (cond
     ((= "A" (cdr [b][color=Red]x[/color][/b]))
      (setq numThree 20))
     ((= "D" (cdr x))
      (setq numThree 40))
     ((= "E" (cdr x))
      (setq numThree 60))
     ((= "S" (cdr x))
      (setq numThree 20))
   )
 )

 

In the above code, you seem to use symbol "y" to allocate to each attribute, and then proceed to use a different symbol "x" when using the cond function. - this could be the reason your variables are not being set.

 

Also, you could test the above theory by adding a final condition:

 

 
 (foreach x blkLst
   (cond
     ((= "A" (cdr x))
      (setq numThree 20))
     ((= "D" (cdr x))
      (setq numThree 40))
     ((= "E" (cdr x))
      (setq numThree 60))
     ((= "S" (cdr x))
      (setq numThree 20))
     (T (princ "\nNo Atrribute Found."))
   )
 )

 
"; error: bad argument type: numberp: nil"

 

This normally means you are feeding the function an argument set to nil. (see above)

 

Hope this helps!

 

Lee

Posted

I am unfortunately still having the problem. I added that test at the end, and it did not print it out, so I am guessing it is with the other two numbers. Here are the routines for each, based on if they are selected radio buttons in the dialog box.

 

 
 (if (= Draw1 "1") (setq numTwo 1))
 (if (= Draw2 "1") (setq numTwo 2))
 (if (= Draw3 "1") (setq numTwo 3))
 (if (= Draw4 "1") (setq numTwo 4))
 (if (= Draw5 "1") (setq numTwo 5))

 

 
 (if (= device1 "1") (setq numOne 1))
 (if (= device2 "1") (setq numOne 10))
 (if (= device3 "1") (setq numOne 100))

 

I am wondering if I need to convert to integers or something after it sets the variable, to insure theya re number values.

Posted

I would consider using "cond" with the options that you have. - but it should work with "if" anyway.

 

and if you are only adding it shouldn't make much difference whether they are integers or not - but if you are later doing a division, then real numbers would be necessary, so converting these to real numbers probably is best.

 

(cond

((= Draw1 "1") (setq numTwo 1.0))

((...etc etc

)

Posted

If you are still having problems, I would recommend that you post the code in its entirety so that I could see if the mistake lies elsewhere. :P

Posted

this is just an example that I am doing in order to then modify for other operations. This is a quick plot app that I was trying to create. If you notice the plot commands at the end, I have to specifically state the scale, rotation, and offsets, in order to get them to plot out correctly through the command line. So, we have 3 seperate plotters and three drawing sizes for this client. I have also included the accompanying .dcl.

 

 
BGEplt: dialog { label = "BGE Quick Plot" ;
: column { label = "Output Device" ;
 : radio_button { key = "dev1" ; label = "HPLJ50001F" ; }
 : radio_button { key = "dev2" ; label = "OceTDS600" ; }
 : radio_button { key = "dev3" ; label = "OceTDS600-2" ; }
}
:column { label = "Plot Size" ;
 : radio_button { key = "pOne" ; label = "A-Size = 8.5x11 in" ; }
 : radio_button { key = "pTwo" ; label = "B-Size = 11x17 in" ; }
 : radio_button { key = "pThree" ; label = "C-Size = 18x24 in" ; }
 : radio_button { key = "pFour" ; label = "D-Size = 24x36 in" ; }
 : radio_button { key = "pFive" ; label = "E-Size = 36x48 in" ; }
}
ok_only;

}

 

 

 
; BGE QUICK PLOT APPLICATION
; This is a program written to expedite the plotting process, and make all output uniform:

(defun C:BGEplt (/ dlg-id dev1 dev2 dev3 device1 device2 device3 OutDev a pOne pTwo pThree pFour pFive Plot1 Plot2 Plot3 Plot4 Plot5 OutPlot numOne numTwo numThree numEq1 numEq2 ss eLst bEnt aEnt aEntLst aVal blkLst)

; Loading the dialog box:

 (setq dlg-id (load_dialog "d:\\users\\501594115\\My Documents\\Work Documents\\Tools\\BGEplt"))
 (new_dialog "BGEplt" dlg-id)

; See which radio buttons the user clicks for plot device:

 (action_tile "dev1" "(setq device1 $value)")
 (action_tile "dev2" "(setq device2 $value)")
 (action_tile "dev3" "(setq device3 $value)")

; De-activate plot options per the selected plot device:

 (action_tile "dev1" "(toggleRadio 1)")
 (action_tile "dev2" "(toggleRadio 2)")
 (action_tile "dev3" "(toggleRadio 2)")
 (defun toggleRadio (a)

 ; If the user clicks Device 1

 (if (= a 1)
   (mode_tile "pThree" 1)
   (mode_tile "pThree" 0))
 (if (= a 1)
   (mode_tile "pFour" 1)
   (mode_tile "pFour" 0))
 (if (= a 1)
   (mode_tile "pFive" 1)
   (mode_tile "pFive" 0))
 (if (= a 1)
   (mode_tile "pTwo" 1)
   (mode_tile "pTwo" 0))
 (if (= a 2)
   (mode_tile "pOne" 1)
   (mode_tile "pOne" 0))
 )

; See which button the user clicks for plot size:

 (action_tile "pOne" "(setq Plot1 $value)")
 (action_tile "pTwo" "(setq Plot2 $value)")
 (action_tile "pThree" "(setq Plot3 $value)")
 (action_tile "pFour" "(setq Plot4 $value)")
 (action_tile "pFive" "(setq Plot5 $value)")
 (start_dialog)
 (unload_dialog dlg-id)

; Set the output device variable and numOne based on selection:

 (if (= device1 "1") (setq numOne 1))
 (if (= device2 "1") (setq numOne 10))
 (if (= device3 "1") (setq numOne 100))

; Set the plot size variable and numTwo based on selection:

 (if (= Plot1 "1") (setq numTwo 1))
 (if (= Plot2 "1") (setq numTwo 2))
 (if (= Plot3 "1") (setq numTwo 3))
 (if (= Plot4 "1") (setq numTwo 4))
 (if (= Plot5 "1") (setq numTwo 5))

; Extract the size value from the title block in order to decide drawing size:

 (vl-load-com)
 (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 66 1)
               (if (getvar "CTAB")
                 (cons 410 (getvar "CTAB"))
                 (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
     (foreach e eLst
   (setq bEnt (cdr (assoc 2 (entget e)))
         aEnt (entnext e))
   (while (= "ATTRIB" (cdr (assoc 0 (setq aEntLst (entget aEnt)))))
     (if (= (cdr (assoc 2 aEntLst)) "SIZE")
       (progn
         (setq aVal (cdr (assoc 1 aEntLst))
           blkLst (cons (cons bEnt aVal) blkLst))))
     (if (= (cdr (assoc 2 aEntLst)) "DWG-TYPE")
(progn
  (setq aVal (cdr (assoc 1 aEntLst))
    blkLst (cons (cons bEnt aVal) blkLst))))
   (setq aEnt (entnext aEnt)))))

; Set the third number variable based on attribute value found:

 (foreach y blkLst
   (cond
     ((= "A" (cdr y))
      (setq numThree 20))
     ((= "D" (cdr y))
      (setq numThree 40))
     ((= "E" (cdr y))
      (setq numThree 60))
     ((= "S" (cdr y))
      (setq numThree 20))
   )
 ))

; Add all three numbers together to get configuration for plotting:

 (setq numEq (+ numOne numTwo numThree))

; Initiate plot command with specified configuration:

 (if (= numEq 22) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\HPLJ50001F" "Letter" "I" "P" "N" "E" "1:1" "Center" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 52) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "B-Size 11x17 in" "I" "P" "N" "E" "1=2.104" "0.16,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 53) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "C-Size 18x24 in" "I" "P" "N" "E" "1=1.454" "0.00,1.11" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 54) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "D-Size 24x36 in" "I" "L" "N" "L" "1:1" "" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 72) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "B-Size 11x17 in" "I" "P" "N" "E" "1=3.225" "1.46,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 73) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "C-Size 18x24 in" "I" "P" "N" "E" "1=1.95" "0.45,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y" ))
 (if (= numEq 74) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "D-Size 24x36 in" "I" "P" "N" "E" "1=1.456" "2.59,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 75) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "E-Size 36x48 in" "I" "P" "N" "E" "1:1" "1.62,0.59" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
(princ)
)

Posted
this is just an example that I am doing in order to then modify for other operations. This is a quick plot app that I was trying to create. If you notice the plot commands at the end, I have to specifically state the scale, rotation, and offsets, in order to get them to plot out correctly through the command line. So, we have 3 seperate plotters and three drawing sizes for this client. I have also included the accompanying .dcl.

 

 
BGEplt: dialog { label = "BGE Quick Plot" ;
: column { label = "Output Device" ;
 : radio_button { key = "dev1" ; label = "HPLJ50001F" ; }
 : radio_button { key = "dev2" ; label = "OceTDS600" ; }
 : radio_button { key = "dev3" ; label = "OceTDS600-2" ; }
}
:column { label = "Plot Size" ;
 : radio_button { key = "pOne" ; label = "A-Size = 8.5x11 in" ; }
 : radio_button { key = "pTwo" ; label = "B-Size = 11x17 in" ; }
 : radio_button { key = "pThree" ; label = "C-Size = 18x24 in" ; }
 : radio_button { key = "pFour" ; label = "D-Size = 24x36 in" ; }
 : radio_button { key = "pFive" ; label = "E-Size = 36x48 in" ; }
}
ok_only;

}

 
; BGE QUICK PLOT APPLICATION
; This is a program written to expedite the plotting process, and make all output uniform:

(defun C:BGEplt (/ dlg-id dev1 dev2 dev3 device1 device2 device3 OutDev a pOne pTwo pThree pFour pFive Plot1 Plot2 Plot3 Plot4 Plot5 OutPlot numOne numTwo numThree numEq1 numEq2 ss eLst bEnt aEnt aEntLst aVal blkLst)

; Loading the dialog box:

 (setq dlg-id (load_dialog "d:\\users\\501594115\\My Documents\\Work Documents\\Tools\\BGEplt"))
 (new_dialog "BGEplt" dlg-id)

; See which radio buttons the user clicks for plot device:

 (action_tile "dev1" "(setq device1 $value)")
 (action_tile "dev2" "(setq device2 $value)")
 (action_tile "dev3" "(setq device3 $value)")

; De-activate plot options per the selected plot device:

 (action_tile "dev1" "(toggleRadio 1)")
 (action_tile "dev2" "(toggleRadio 2)")
 (action_tile "dev3" "(toggleRadio 2)")
 (defun toggleRadio (a)

 ; If the user clicks Device 1

 (if (= a 1)
   (mode_tile "pThree" 1)
   (mode_tile "pThree" 0))
 (if (= a 1)
   (mode_tile "pFour" 1)
   (mode_tile "pFour" 0))
 (if (= a 1)
   (mode_tile "pFive" 1)
   (mode_tile "pFive" 0))
 (if (= a 1)
   (mode_tile "pTwo" 1)
   (mode_tile "pTwo" 0))
 (if (= a [b][color=Red]2[/color][/b])
   (mode_tile "pOne" 1)
   (mode_tile "pOne" 0))
 )

; See which button the user clicks for plot size:

 (action_tile "pOne" "(setq Plot1 $value)")
 (action_tile "pTwo" "(setq Plot2 $value)")
 (action_tile "pThree" "(setq Plot3 $value)")
 (action_tile "pFour" "(setq Plot4 $value)")
 (action_tile "pFive" "(setq Plot5 $value)")
 (start_dialog)
 (unload_dialog dlg-id)

; Set the output device variable and numOne based on selection:

 (if (= device1 "1") (setq numOne 1))
 (if (= device2 "1") (setq numOne 10))
 (if (= device3 "1") (setq numOne 100))

; Set the plot size variable and numTwo based on selection:

 (if (= Plot1 "1") (setq numTwo 1))
 (if (= Plot2 "1") (setq numTwo 2))
 (if (= Plot3 "1") (setq numTwo 3))
 (if (= Plot4 "1") (setq numTwo 4))
 (if (= Plot5 "1") (setq numTwo 5))

; Extract the size value from the title block in order to decide drawing size:

 (vl-load-com)
 (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 66 1)
               (if (getvar "CTAB")
                 (cons 410 (getvar "CTAB"))
                 (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
     (foreach e eLst
   (setq bEnt (cdr (assoc 2 (entget e)))
         aEnt (entnext e))
   (while (= "ATTRIB" (cdr (assoc 0 (setq aEntLst (entget aEnt)))))
     (if (= (cdr (assoc 2 aEntLst)) "SIZE")
       (progn
         (setq aVal (cdr (assoc 1 aEntLst))
           blkLst (cons (cons bEnt aVal) blkLst))))
     (if (= (cdr (assoc 2 aEntLst)) "DWG-TYPE")
(progn
  (setq aVal (cdr (assoc 1 aEntLst))
    blkLst (cons (cons bEnt aVal) blkLst))))
   (setq aEnt (entnext aEnt)))))

; Set the third number variable based on attribute value found:

 (foreach y blkLst
   (cond
     ((= "A" (cdr y))
      (setq numThree 20))
     ((= "D" (cdr y))
      (setq numThree 40))
     ((= "E" (cdr y))
      (setq numThree 60))
     ((= "S" (cdr y))
      (setq numThree 20))
   )
 ))

; Add all three numbers together to get configuration for plotting:

 (setq numEq (+ numOne numTwo numThree))

; Initiate plot command with specified configuration:

 (if (= numEq 22) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\HPLJ50001F" "Letter" "I" "P" "N" "E" "1:1" "Center" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 52) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "B-Size 11x17 in" "I" "P" "N" "E" "1=2.104" "0.16,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 53) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "C-Size 18x24 in" "I" "P" "N" "E" "1=1.454" "0.00,1.11" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 54) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "D-Size 24x36 in" "I" "L" "N" "L" "1:1" "" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 72) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "B-Size 11x17 in" "I" "P" "N" "E" "1=3.225" "1.46,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 73) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "C-Size 18x24 in" "I" "P" "N" "E" "1=1.95" "0.45,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y" ))
 (if (= numEq 74) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "D-Size 24x36 in" "I" "P" "N" "E" "1=1.456" "2.59,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
 (if (= numEq 75) (command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "E-Size 36x48 in" "I" "P" "N" "E" "1:1" "1.62,0.59" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))
(princ)
)

 

 

I don't know very much about dialog boxes as such, as I have never used them myself, but, just curious, is the highlighted above correct?

Posted

Yeah, that is right. That is deciding which options to de-activate (gray out) when a given one is selected. It is in reference to

 

 
(action_tile "dev1" "(toggleRadio 1)")
(action_tile "dev2" "(toggleRadio 2)")
(action_tile "dev3" "(toggleRadio 2)")

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...