Jump to content

Need help extracting attribute values in Lisp


Recommended Posts

Posted

Ok, heres an idea, run this code:

 

 ; 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:

[b][color=Red] (alert (strcat
      "Variable Values: \n\nnumOne: "
      (vl-princ-to-string numOne)
      "\nnumTwo: "
      (vl-princ-to-string numTwo)
      "\nnumThree: "
      (vl-princ-to-string numThree)))[/color][/b]

 (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)
 )

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • Archiman86

    16

  • Lee Mac

    15

Posted

I loaded that and tried to run it. The alert showed:

 

 
numOne: nil
numTwo: 2
numThree: nil

 

I got the numOne to work, by removing the "toggleradio" function. I figured out that that was reassigning the value of the radio buttons and therefore not assigning the variables correctly. I also changed the "IF" functions over to one "conditional" function.

 

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

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

 

However, I am still having problems with the third number. I tried using "atoi" to convert it to an integer, and it still shows up nil. I am not sure what the solution is going to be here.

Posted

When using the conditional function set numThree, you are setting it as an integer, so you will not need to do any conversion.

 

However, I am slightly concerned at this point, as its my code that is providing the value for numThree - so my reputation is at stake :)

 

Although I note that you have changed my code to add an extra attribute tag value...

 

 

OK.... With more careful analysis of the code - I have found your mistake.

 

 ; 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)))))
     (cond ((= (cdr (assoc 2 aEntLst)) "SIZE")
        (setq aVal   (cdr (assoc 1 aEntLst))
              blkLst (cons (cons bEnt aVal) blkLst)))
       ((= (cdr (assoc 2 aEntLst)) "DWG-TYPE")
        (setq aVal   (cdr (assoc 1 aEntLst))
              blkLst (cons (cons bEnt aVal) blkLst))))
     (setq aEnt (entnext aEnt)[b][color=Red])))[/color][/b]

 ; 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))
   )
     )[b][color=Red]))[/color][/b]

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

 (alert (strcat
      "Variable Values: \n\nnumOne: "
      (vl-princ-to-string numOne)
      "\nnumTwo: "
      (vl-princ-to-string numTwo)
      "\nnumThree: "
      (vl-princ-to-string numThree)))

 (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)
 )

In the above, I have altered the code to use "cond" when retrieving the attributes.

 

But, where you stripped my code of the function definition, you left the "if" statement without an extra bracket, but closed the bracket after the code wrapper (progn). Therefore, this means that "if" the program did find some blocks, it would not write the variables and would only write the variables when the ssget returned nil. - in which case it would have no values to write.

 

Hope it works now. :)

Posted

Lee, Thanks alot! that works great now. I really appreciate all the help you have given. And just for the record, the error was definitely my fault, and not yours. The code that you gave me worked great. It was my effort to modify it that created the error. Thank you for the explanation and I understand now why it was not working. Also, if there is anything that you would recommend that I do in order to make this code more concise, let me know. I am going to go through and cahnge all of the "If" statements to "cond" now that it is working.

 

Dan

Posted

Excellent! Glad it is working for you now :)

 

It was only a minor mistake in altering the code, but one that had quite major effects :P

 

The use of "cond" instead of "if" would make the program run slightly faster, and my emphasis is on the "slightly" here as, with todays processors, I doubt that you would see much of a difference to be honest.

 

But, because with the cond, it runs through each condition and stops when a condition returns true, not every condition is evaluated/tested. Whereas with the use of "if", each "if" statement is tested even after one of the other "if" statements has returned true. ~ which, when put like this, seems a bit pointless. :)

 

Anyway, hope you have learnt from working through this problem - I know I have! :)

 

Cheers

 

Lee

  • 2 months later...
Posted

Hey Lee,

 

I was wondering if you could help me out with this. I am back working on this, but I am changing it all around so that I can work with multiple clients, in one Lisp file. I am trying to set up multiple funcitons withint he file and so forth. This is the first time I have tried anything this intricate. Any help or guidance would be greatly appreciated. I would like to make it so that there is less code. I am trying to combine as many functions as possible. When you get a chance, please look this over. I have not tried it yet.

 

 

(defun GEplt (/)

 

;==================================

;==>Initiate function for ENERGY

;==================================

(defun C:ENERGYplt (/ dlg-id dev1 dev2 dev3 device1 device2 device3 OutDev pOne pTwo pThree Plot1

Plot2 Plot3 OutPlot numOne numTwo numEq)

;

; -->Make sure drawing is in Model Space

;

 

(if (= (getvar "TILEMODE") 0)

(Setvar "TILEMODE" 1))

;

; -->Setup/Load Dialog box

;

 

(setq dlg-id (load_dialog "Q:\\std\\acad\\support\\lisp\\GEplt.dcl"))

(new_dialog "ENERGYplt" dlg-id)

 

(progn

(action_tile "dev1" "(setq device# 1)")

(action_tile "dev2" "(setq device# 2)")

(action_tile "dev3" "(setq device# 3)")

)

 

(progn

(action_tile "pOne" "(setq Plot# 1)")

(action_tile "pTwo" "(setq Plot# 2)")

(action_tile "pThree" "(setq Plot# 3)")

)

 

(start_dialog)

(unload_dialog dlg-id)

(GEvars)

(GEplot)

(princ)

)

 

 

 

;================================

;==>Initiate function for BG&E

;================================

(defun C:BGEplt (/ dlg-id dev1 dev2 dev3 dev4 dev5 device1 device2 device3 device4 device5 OutDev

a pOne pTwo pThree pFour pFive Plot1 Plot2 Plot3 Plot4 Plot5 OutPlot numOne

numTwo numThree numEq ss eLst bEnt aEnt aEntLst aVal blkLst)

 

;

; -->Make sure drawing is in Paper Space

;

(if (= (getvar "TILEMODE") 1)

(Setvar "TILEMODE" 0))

;

; -->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))

)

)))

;

; -->Setup/Load Dialog box

;

(setq dlg-id (load_dialog "Q:\\std\\acad\\support\\lisp\\GEplt.dcl"))

(new_dialog "BGEplt" dlg-id)

 

(if

(= numThree 20)

(progn

(action_tile "dev1" "(setq device# 1)")

(mode_tile "dev2" 1)

(mode_tile "dev3" 1)

(mode_tile "dev4" 1)

(action_tile "dev5" "(setq device# 5)")

(action_tile "pOne" "(setq Plot# 1)")

(mode_tile "pTwo" 1)

(mode_tile "pThree" 1)

(mode_tile "pFour" 1)

(mode_tile "pFive" 1)

)

)

 

(if

(= numThree 40)

(progn

(mode_tile "dev1" 1)

(action_tile "dev2" "(setq device# 2)")

(action_tile "dev3" "(setq device# 3)")

(action_tile "dev4" "(setq device# 4)")

(action_tile "dev5" "(setq device# 5)")

(mode_tile "pOne" 1)

(action_tile "pTwo" "(setq Plot# 2)")

(action_tile "pThree" "(setq Plot# 3)")

(action_tile "pFour" "(setq Plot# 4)")

(mode_tile "pFive" 1)

)

)

 

(if

(= numThree 60)

(progn

(mode_tile "dev1" 1)

(action_tile "dev2" "(setq device# 2)")

(action_tile "dev3" "(setq device# 3)")

(action_tile "dev4" "(setq device# 4)")

(action_tile "dev5" "(setq device# 5)")

(mode_tile "pOne" 1)

(action_tile "pTwo" "(setq Plot# 2)")

(action_tile "pThree" "(setq Plot# 3)")

(action_tile "pFour" "(setq Plot# 4)")

(action_tile "pFive" "(setq Plot# 5)")

)

)

 

(start_dialog)

(unload_dialog dlg-id)

(GEvars)

(GEplot)

(princ)

)

 

 

 

;==========================================================

;==>Set Variable based on dialog selections and add them

;==========================================================

 

(defun GEvars (/ device1 device2 device3 device4 device5 dev1 dev2 dev3 dev4 dev5 OutDev Plot1 Plot2 Plot3 Plot4 Plot5

pOne pTwo pThree pFour pfive numOne numTwo numEq)

 

(cond

((= device# 1) (setq numOne 1))

((= device# 2) (setq numOne 10))

((= device# 3) (setq numOne 100))

((= device# 4) (setq numOne 1000))

((= device# 5) (setq numOne 10000))

)

(cond

((= Plot# 1) (setq numTwo 1))

((= Plot# 2) (setq numTwo 2))

((= Plot# 3) (setq numTwo 3))

((= Plot# 4) (setq numTwo 4))

((= Plot# 5) (setq numTwo 5))

)

;(alert (strcat

; "Variable Values: \n\nnumOne: "

; (vl-princ-to-string numOne)

; "\nnumTwo: "

; (vl-princ-to-string numTwo)

; "\nnumThree: "

;(vl-princ-to-string numThree)))

(setq numEq (+ numOne numTwo numThree))

(princ)

)

 

 

 

 

;=======================================================

;==>Initiate the plot command based on user selection

;=======================================================

 

(defun GEplot (/ numEq)

 

(cond

((= 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"))

((= numEq 52)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "Oce B 11x17 in" "I" "P" "N" "E" "1=2.104" "0.16,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 53)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "Oce C+ 18x24 in" "I" "P" "N" "E" "1=1.454" "0.00,1.11" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N""N" "Y"))

((= numEq 54)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "Oce D+ 24x36 in" "I" "L" "N" "L" "1:1" "" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 142)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "Oce B 11x17 in" "I" "P" "N" "E" "1=2.104" "0.16,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 143)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "Oce C+ 18x24 in" "I" "P" "N" "E" "1=1.454" "0.00,1.11" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N""N" "Y"))

((= numEq 144)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "Oce D+ 24x36 in" "I" "L" "N" "L" "1:1" "" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 72)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "Oce B 11x17 in" "I" "P" "N" "E" "1=3.225" "1.46,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 73)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "Oce C+ 18x24 in" "I" "P" "N" "E" "1=1.95" "0.45,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 74)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "Oce D+ 24x36 in" "I" "L" "N" "E" "1=1.456" "2.59,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 75)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600" "Oce E+ 36x48 in" "I" "P" "N" "E" "1:1" "1.62,0.59" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

 

((= numEq 162)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "Oce B 11x17 in" "I" "P" "N" "E" "1=3.225" "1.46,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 163)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "Oce C+ 18x24 in" "I" "P" "N" "E" "1=1.95" "0.45,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 164)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "Oce D+ 24x36 in" "I" "L" "N" "E" "1=1.456" "2.59,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 165)

(command "-plot" "Y" "Layout1" "\\\\ilordf08psge\\OceTDS600-2" "Oce E+ 36x48 in" "I" "P" "N" "E" "1:1" "1.62,0.59" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 10021)

(command "-plot" "Y" "Layout1" "PDF995" "Letter" "I" "P" "N" "E" "1:1" "CENTER" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

 

((= numEq 10042)

(command "-plot" "Y" "Layout1" "PDF995" "Tabloid" "I" "P" "N" "E" "1=2.104" "0.16,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 10043)

(command "-plot" "Y" "Layout1" "PDF995" "ARCH C" "I" "P" "N" "E" "1=1.95" "0.45,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 10044)

(command "-plot" "Y" "Layout1" "PDF995" "ARCH D" "I" "L" "N" "L" "1:1" "" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 10062)

(command "-plot" "Y" "Layout1" "PDF995" "Tabloid" "I" "L" "N" "E" "1=3.225" "1.46,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 10063)

(command "-plot" "Y" "Layout1" "PDF995" "ARCH C" "I" "L" "N" "E" "1=1.95" "0.45,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 10064)

(command "-plot" "Y" "Layout1" "PDF995" "ARCH D" "I" "L" "N" "E" "1=1.456" "2.59,0.0" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

((= numEq 10065)

(command "-plot" "Y" "Layout1" "PDF995" "ARCH E" "I" "L" "N" "E" "1:1" "1.62,0.59" "Y" "monochrome.ctb" "Y" "Y" "N" "N" "N" "N" "Y"))

)

(princ)

)

 

 

 

(princ)

)

 

 

Thanks in advance...

 

-Dan

Posted

I am having trouble running this. Is it not possible to call functions within functions. For example, how it is written right now, If I type "BGEplt" into command line, it says "unknown command". Do I need to re-work it so that there is only one function caleed and then the functions contained within that are only working within, if that makes sense?

Posted

You don't need to wrap the whole code in another function definition - try this, haven't really got much time atm sorry. :(

tmp.lsp

Posted

thats ok, thanks for the input. I got it to run now. Thanks. Also, I was wondering, The other clients we work with do all their work in model space, unfortunately. So, instead of pulling an attribute value, I need to pull a scale factor from the title block. Is this possible?

Posted

Yes, this is possible -

 

 

In VL:

 

(defun c:testVL (/ ent scl)
 (setq ent (vlax-ename->vla-object (car (entsel "\nSelect Block: ")))
   scl (list (vla-get-xscalefactor ent)
         (vla-get-yscalefactor ent)
         (vla-get-zscalefactor ent)))
 (alert (vl-princ-to-string scl))
 (princ))

 

Or in Common LISP:

 

(defun c:testCL (/ ent scl)
 (setq ent (entget (car (entsel "\nSelect Block: ")))
   scl (list (cdr (assoc 41 ent))
         (cdr (assoc 42 ent))
         (cdr (assoc 43 ent))))
 (alert (vl-princ-to-string scl))
 (princ))

  • 10 months later...
Posted

I now have another question. I have some users complaining about having to open each individual file and plot individually. Do you have any idea how I can use what was already created in order to create a similar batch plot routine (i have tried setting up page setups and using publish, but I always have problems with it and would prefer a different option). I would like it to still be able to extract the attribute from the title block and plot according to what was chosen by user originally. Ideally I would like it to be a program run within an instance of AutoCad (if possible) that askes you to select drawings, what size and which plotter, and then opens each drawing and uses this routine (or a similar one) to extract the attribute and plot accordingly. I am sure this is possible using VBA, but since I know nothing about it, I was wondering if its posisble maybe using Lisp or batch files. Any help or insight would be greatly appreciated. Thanks again!

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...