Below is my code that I am working on. Everything works good by there selves, but when I put it together and try and utilize a reactor I cant seem to get it to work. I am trying to get the reactor to call the areas function when a save is issued. Then it should update everything. It works if I do everything manually by calling the areas command and then hitting the save button. Can someone please give me some direction here. Thanks.
Code:
(setq PLANPATH2 (getvar "DWGPREFIX"))
(setq DATAFILENAME2 "Areadata.txt")
(setq ardt (strcat planpath2 datafilename2))
(setq found2 (findfile ardt))
(if (/= found2 ardt)
(progn
(alert "AREAS NOT SETUP")
(princ)
)
)
(if (= found2 ardt)
(progn
(setq fo2 (open ardt "r"))
(setq sft1 (atof(read-line fo2)))
(setq sft2 (atof(read-line fo2)))
(setq cft1 (atof(read-line fo2)))
(setq cft2 (atof(read-line fo2)))
(setq deductft (atof(read-line fo2)))
(setq garft (atof(read-line fo2)))
(setq ssft (atof(read-line fo2)))
(setq deckft (atof(read-line fo2)))
(setq cpft (atof(read-line fo2)))
(setq nssft (atof(read-line fo2)))
(setq unfinft (atof(read-line fo2)))
(setq carportft (atof(read-line fo2)))
(setq basementft (atof(read-line fo2)))
(close fo2)
)
)
(vl-load-com)
(vlr-dwg-reactor nil '((:vlr-beginSave . AREAS)))
(defun AREAS ()
(defun FilterClrNumbX(eset valu)
(setq valu(atoi valu) layerList(list))
(setq tbl(tblnext "LAYER" T))
(if(= valu (cdr(assoc 62 tbl)))
(setq layerList(append layerList (list (cdr(assoc 2 tbl)))))
)
(while(setq tbl(tblnext "LAYER"))
(if(= valu (cdr(assoc 62 tbl)))
(setq layerList(append layerList (list (cdr(assoc 2 tbl)))))
)
)
(setq cntr 0 newSet(ssadd))
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq enlist(entget en))
(if (assoc 62 enlist)
(if(= valu (cdr(assoc 62 enlist)))
(ssadd en newSet)
)
(if(member (cdr(assoc 8 enlist)) layerList)
(ssadd en newSet)
)
)
(setq cntr(+ cntr 1))
)
newSet
)
(defun FilterLayNameX(eset valu)
(setq cntr 0 newSet(ssadd))
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq enlist(entget en))
(if(= valu (cdr(assoc 8 enlist)))
(ssadd en newSet)
)
(setq cntr(+ cntr 1))
)
newSet
)
(setvar "cmdecho" 0)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "5")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq sft1(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "164")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq sft2(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "3")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq cft1(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "84")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq cft2(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "9")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq deductft(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "1")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq garft(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "6")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq ssft(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "30")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq deckft(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "7")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq cpft(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "8")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq nssft(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "3")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq unfinft(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "11")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq carportft(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq eset(ssget "X" (list(cons 0 "LWPOLYLINE"))))
(if(and eset(> (sslength eset) 0))(setq eset(FilterClrNumbX eset "2")))
(if(and eset(> (sslength eset) 0))(setq eset(FilterLayNameX eset "1-AREA-BS")))
(if (and eset (> (sslength eset) 0))
(progn
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq basementft(getArea en))
(setq cntr(+ cntr 1))
)
)
)
(setq fo3 (open ardt "w"))
(princ sft1 fo3)
(princ "\n" fo3)
(princ sft2 fo3)
(princ "\n" fo3)
(princ cft1 fo3)
(princ "\n" fo3)
(princ cft2 fo3)
(princ "\n" fo3)
(princ deductft fo3)
(princ "\n" fo3)
(princ garft fo3)
(princ "\n" fo3)
(princ ssft fo3)
(princ "\n" fo3)
(princ deckft fo3)
(princ "\n" fo3)
(princ cpft fo3)
(princ "\n" fo3)
(princ nssft fo3)
(princ "\n" fo3)
(princ unfinft fo3)
(princ "\n" fo3)
(princ carportft fo3)
(princ "\n" fo3)
(princ basementft fo3)
(princ)
(close fo3)
(setvar "cmdecho" 1)
(princ)
)