woodman78 Posted November 30, 2010 Share Posted November 30, 2010 I have this lisp that fixo wrote for me some time back. I have been trying to in a dcl that will ask for the landowner name and the folio number and setup the layers with these as part of the name. The dialog flashes up and closes after a second. Can anyone help? ;; local defun by CAB (Charles Alan Butler) (defun LayerMake_CPO (lyrname Color ltype) (if (tblsearch "LAYER" lyrname) (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname "") (command "._Layer" "_Make" lyrname "_Color" (if (or (null color)(= Color "")) "_White" Color) lyrname "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname "") ) ) (defun C:CPO (/ *error* ang col clr coords dwo elist midp offsetted ofpt osm p1 p2 p3 pline a b c name folio) (setq dcl_id (load_dialog "cpo.dcl")) (if (not (new_dialog "cpo" dcl_id)) (exit) );if (action_tile "name" (setq name $value)) (action_tile "folio" (setq folio $value)) ;(action_tile "accept" (val1)) (start_dialog) (unload_dialog dcl_id) (setq a (strcat "CCC_CPO_"name"_"folio"_Grey_Hatch") b (strcat "CCC_CPO_"name"_"folio"_Outline_Red") c (strcat "CCC_CPO_"name"_"folio"_Outline_Black")) (defun *error* (msg) (if (vl-position msg '("console break" "Function cancelled" "quit / exit abort" ) ) (princ "Error!") (princ msg) ) (if osm (setvar "osmode" osm)) (if clr (setvar "clayer" clr)) (if col (setvar "cecolor" col)) (if dwo (setvar "draworderctl" dwo)) (command "._undo" "_END") ) (setq osm (getvar "osmode")) (setq col (getvar "cecolor")) (setq clr (getvar "clayer")) (setq dwo (getvar "draworderctl")) (command "._undo" "_BE") (setvar "osmode" 2593) (setvar "cecolor" "bylayer") (setvar "HPORIGINMODE" 5) (LayerMake_CPO a "254" "Continuous") (LayerMake_CPO b "1" "Continuous") (LayerMake_CPO c "7" "Continuous") (setvar "clayer" c) (command "._pline") (while (= 1 (logand 1 (getvar "cmdactive"))) (command pause)) (setq pline (entlast) elist (entget pline) ) (setq elist (entmod (subst (cons 70 1)(assoc 70 elist)elist)));<--close pline (entmod (subst (cons 43 0)(assoc 43 elist)elist));<--set line width to zero (setvar "draworderctl" 3) (command "_.draworder" pline "" "_F");<--set pline's draw order to front (setq coords (vl-remove-if (function not) (mapcar (function (lambda (x) (if (= 10 (car x))(cdr x)))) elist)) ) (setq p3 (caddr coords) p1 (car coords) ang (angle p1 p3) ofpt (polar p3 ang 1.0) ) (setvar "clayer" "CCC_CPO_Replace with landwoner name_Outline_Red") (command "._offset" 0.5 pline ofpt "") (setq offsetted (entlast) elist (entget offsetted) ) (if (assoc 62 elist) (setq elist (subst (cons 62 1)(assoc 62 elist) elist )) (setq elist (append elist (list '(62 . 1)))) ) (entmod elist) (command "._pedit" offsetted "_W" 1.0 "") (command "_.draworder" offsetted "" "_B");<--set pline's draw order to back (setq coords (vl-remove-if (function not) (mapcar (function (lambda (x) (if (= 10 (car x))(cdr x)))) elist)) ) (setq p2 (car coords) midp (mapcar (function (lambda( a b)(/ (+ a b) 2))) p1 p2) ) (setvar "clayer" "CCC_CPO_Replace with landwoner name_Grey_Hatch") (setvar "hpname" "SOLID") (command "-hatch" "S" pline "" "") (setvar "hpname" ".") ;(Alert "Don't forget to change the landowner name & plot number LAYERS in the LAYER window!!!") (*error* nil) (princ) ) cpo: dialog {label = "CPO Layer Creation"; : edit_box { label = "Enter landowner name :"; key = "name"; alignment = centered; edit_limit = 30; edit_width = 30; } : edit_box { label = "Enter folio number :"; key = "folio"; alignment = centered; edit_limit = 10; edit_width = 30; } : button { key = "accept"; label = "OK"; is_default = true; fixed_width = true; alignment = centered; } : errtile { width = 34; } } Quote Link to comment Share on other sites More sharing options...
pBe Posted November 30, 2010 Share Posted November 30, 2010 (action_tile "name" "(setq name $value)") (action_tile "folio" "(setq folio $value)") Quote Link to comment Share on other sites More sharing options...
woodman78 Posted November 30, 2010 Author Share Posted November 30, 2010 Thanks pBe. That did the job. Quote Link to comment Share on other sites More sharing options...
woodman78 Posted December 1, 2010 Author Share Posted December 1, 2010 I have that working now. I made some additional changes. I have added a mleader extension to the lisp so that on completion of the closed pline it launches an mleader to label the parcel. It does work but when the pline finished I get the following at the command line: Command: nil Invalid Input. I then right click and it continues on and creates the mleader. Can anyone spot why this is happening? The other thing is that there is a section in the code where if offsets the line drawn and creates a selection set with the last thing created but it doesn't transfer it to layer b as it should. I tried a few solutions but keep getting stuck. Can anyone help? Thanks. ;; local defun by CAB (Charles Alan Butler) (defun LayerMake_CPO (lyrname Color ltype) (if (tblsearch "LAYER" lyrname) (command "._Layer" "_Thaw" lyrname "_On" lyrname "_UnLock" lyrname "_Set" lyrname "") (command "._Layer" "_Make" lyrname "_Color" (if (or (null color)(= Color "")) "_White" Color) lyrname "LT" (if (or (null ltype)(= ltype "")) "Continuous" ltype) lyrname "") ) ) (defun C:CPO (/ *error* ang col clr coords dwo elist midp offsetted ofpt osm p1 p2 p3 pline a b c name folio) (setq dcl_id (load_dialog "cpo.dcl")) (if (not (new_dialog "cpo" dcl_id)) (exit) );if (action_tile "name" "(setq name $value)") (action_tile "folio" "(setq folio $value)") ;(action_tile "accept" (val1)) (start_dialog) (unload_dialog dcl_id) (setq a (strcat "CCC_CPO_"name"_"folio"_Grey_Hatch") b (strcat "CCC_CPO_"name"_"folio"_Outline_Red") c (strcat "CCC_CPO_"name"_"folio"_Outline_Black") d (strcat "CCC_CPO_"name"_"folio"_Leader")) (defun *error* (msg) (if (vl-position msg '("console break" "Function cancelled" "quit / exit abort" ) ) (princ "Error!") (princ msg) ) (if osm (setvar "osmode" osm)) (if clr (setvar "clayer" clr)) (if col (setvar "cecolor" col)) (if dwo (setvar "draworderctl" dwo)) (command "._undo" "_END") ) (Alert "Remember to draw the plot outline in an ANTI-CLOCKWISE direction.") (command "_.insert" "CCC_CPO_Leader_Styles=" nil) (command "_.purge" "_b" "CCC_CPO_Leader_Styles" "_n") (setq osm (getvar "osmode")) (setq col (getvar "cecolor")) (setq clr (getvar "clayer")) (setq dwo (getvar "draworderctl")) (command "._undo" "_BE") (setvar "osmode" 2593) (setvar "cecolor" "bylayer") (setvar "HPORIGINMODE" 5) (LayerMake_CPO a "254" "Continuous") (LayerMake_CPO b "1" "Continuous") (LayerMake_CPO c "7" "Continuous") (LayerMake_CPO d "7" "Continuous") (setvar "clayer" c) (command "._pline") (while (= 1 (logand 1 (getvar "cmdactive"))) (command pause)) (setq pline (entlast) elist (entget pline) ) (setq elist (entmod (subst (cons 70 1)(assoc 70 elist)elist)));<--close pline (entmod (subst (cons 43 0)(assoc 43 elist)elist));<--set line width to zero (setvar "draworderctl" 3) (command "_.draworder" pline "" "_F");<--set pline's draw order to front (setq coords (vl-remove-if (function not) (mapcar (function (lambda (x) (if (= 10 (car x))(cdr x)))) elist)) ) (setq p3 (caddr coords) p1 (car coords) ang (angle p1 p3) ofpt (polar p3 ang 1.0) ) (setvar "clayer" b) (command "._offset" 0.5 pline ofpt "") (setq offsetted (entlast) elist (entget offsetted) ) ;(command "chprop" offsetted "LA" b "") ;(command "_change" offsetted "" "p" "layer" b "color" "bylayer" "") (if (assoc 62 elist) (setq elist (subst (cons 62 1)(assoc 62 elist) elist )) (setq elist (append elist (list '(62 . 1)))) ) (entmod elist) (command "._pedit" offsetted "_W" 1.0 "") (command "_.draworder" offsetted "" "_B");<--set pline's draw order to back (setq coords (vl-remove-if (function not) (mapcar (function (lambda (x) (if (= 10 (car x))(cdr x)))) elist)) ) (setq p2 (car coords) midp (mapcar (function (lambda( a b)(/ (+ a b) 2))) p1 p2) ) (setvar "clayer" a) (setvar "hpname" "SOLID") (command "-hatch" "S" pline "" "") ;(while (> (getvar "cmdactive") 0) ;(command "\\") ;<- The Pause symbol will not pause the command. Backslash used instead. (setvar "hpname" ".") (setvar "clayer" d) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (if (null (tblsearch "STYLE" "CCC_CPO_Leader")) (progn (entmake (list (cons 0 "STYLE") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbTextStyleTableRecord") (cons 2 "CCC_Note_Numbers") (cons 3 "Verdana.ttf") (cons 40 0) (cons 74 1) ;Bold (cons 70 0))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setvar "textstyle" "CCC_CPO_Leader") (setvar "CMLEADERSTYLE" "CCC_CPO_Leader") (setvar "CMDECHO" 0) (setvar "OSMODE" 0) (command "_.mleader") (*error* nil) (princ) ) Quote Link to comment Share on other sites More sharing options...
pBe Posted December 1, 2010 Share Posted December 1, 2010 (edited) ? (command "_.insert" "CCC_CPO_Leader_Styles=" nil)<------------ what is the "=" for? check this part (*error* nil)<-------- check this one check that part of your code Edited December 1, 2010 by pBe Quote Link to comment Share on other sites More sharing options...
woodman78 Posted December 1, 2010 Author Share Posted December 1, 2010 pBe, That is to insert the definition of a block in order to insert mleader styles into the drawing. Quote Link to comment Share on other sites More sharing options...
pBe Posted December 1, 2010 Share Posted December 1, 2010 pBe,That is to insert the definition of a block in order to insert mleader styles into the drawing. I see... (*error* nil)<-------- check this one and this? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 1, 2010 Share Posted December 1, 2010 I see... (*error* nil)<-------- check this one and this? Some people call the Error Handler silently to reset Sys Variables and the like You can use a custom handler which tests for the string argument: (defun *error* ( m ) (if m (princ m) (princ) ) Quote Link to comment Share on other sites More sharing options...
pBe Posted December 1, 2010 Share Posted December 1, 2010 (edited) I see... (*error* nil)<-------- check this one and this? I know.... thats whats causing that nil message you're seeing EDIT: Message for Woodman Edited December 1, 2010 by pBe Lee mac beat me to it Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 1, 2010 Share Posted December 1, 2010 I realise perhaps your post was directed at Woodman and I haven't properly looked at nor tested the code, however that could not cause the error message since firstly there is nothing in the error handler that could error by taking a nil 'msg' argument. Also, if the error handler was throwing the error you would receive 'An error occurred inside the *error* function....' which I don't believe is the case. Apologies for sticking my nose in, but didn't want a wild goose chase... Quote Link to comment Share on other sites More sharing options...
pBe Posted December 1, 2010 Share Posted December 1, 2010 Apologies for sticking my nose in, but didn't want a wild goose chase... No worries Lee Your "nose" is welcome anytime I realise perhaps your post was directed at Woodman and I haven't properly looked at nor tested the code, however that could not cause the error message since firstly there is nothing in the error handler that could error by taking a nil 'msg' argument. Also, if the error handler was throwing the error you would receive 'An error occurred inside the *error* function....' which I don't believe is the case. You're right about that.. but for this particuar code , it does.. so defining it differently will make that message go away.. (i guess ) Quote Link to comment Share on other sites More sharing options...
woodman78 Posted December 6, 2010 Author Share Posted December 6, 2010 Thanks guys. pBe that did the trick alright. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.