CHLUCFENG Posted June 4, 2010 Share Posted June 4, 2010 I have a block that contains three attributes representing width, length, and sq. footage for windows. I have written a simple code to insert the block into a drawing, and repeat as long as the user would like. The problem is that I am getting an error from the -Insert command that is producing an "Invalid option keyword." error message. (defun c:ATO-Windows () (c:utility-start) (setvar "osmode" 0) (SETVAR "TEXTEVAL" 1) (setq ATOLayer "AreaTakeOff-Window" ATOLayerColor "143" ATOLineType "Continuous" ATOBlkWPath "C:/ACAD2008/HVAC/BLOCKS/ATTR-WINDOW" ) (command "layer" "on" ATOLayer "thaw" ATOLayer "m" ATOLayer "C" ATOLayerColor ATOLayer "Ltype" ATOLineType "" ) (setq continue "T") (while continue (setq WindowLength "0" WindowWidth "0" ) (setq WindowLength (getstring "\nEnter Window Length in feet: ")) (setq WindowWidth (getstring "\tWidth in feet: ")) (setq RealLength (atof WindowLength) RealWidth (atof WindowWidth) ) (setq RealArea (* RealLength RealWidth)) (setq WindowArea (strcat (rtos RealArea 2 2) "SF")) (SETVAR "ATTDIA" 0) (terpri) (if (> RealArea 0.0) (command "-insert" ATOBlkWPath "Scale" (getvar "Userr3") Pause "0" WindowLength WindowWidth WindowArea ) (setq continue nil) ) ;end if ) ;end while (c:utility-end) (SETVAR "ATTDIA" 1) ) ;end c:ATO-Windows Block attached, set a path to test this code. I do not see why I have the error. Perhaps a fresh set of eyes will spot something. Thanks, CL ATTR-WINDOW.dwg Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 5, 2010 Share Posted June 5, 2010 Quite a few gotchas but the big one is that you have the ATTDEFs verification bit set. I took a shot at cleaning it up a bit: [b][color=BLACK]([/color][/b]defun c:ATO-Windows [b][color=FUCHSIA]([/color][/b]/ ATOLayer ATOLayerColor ATOLineType ATOBlkWPath WindowLength WindowWidth RealArea WindowArea ipt[b][color=FUCHSIA])[/color][/b] [color=#8b4513]; [b][color=FUCHSIA]([/color][/b]c:utility-start[b][color=FUCHSIA])[/color][/b][/color] [color=#8b4513]; [b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"osmode"[/color] 0[b][color=FUCHSIA])[/color][/b][/color] [b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"CMDECHO"[/color] 0[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]getvar [color=#2f4f4f]"USERR3"[/color][b][color=MAROON])[/color][/b] 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setvar [color=#2f4f4f]"USERR3"[/color] 4.8[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq ATOLayer [color=#2f4f4f]"AreaTakeOff-Window"[/color] ATOLayerColor [color=#2f4f4f]"143"[/color] ATOLineType [color=#2f4f4f]"Continuous"[/color] ATOBlkWPath [color=#2f4f4f]"C:/ACAD/AWINDOW"[/color] [color=#8b4513]; 2008/HVAC/BLOCKS/ATTR-WINDOW[/color] [b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]not [b][color=MAROON]([/color][/b]tblsearch [color=#2f4f4f]"LAYER"[/color] ATOLayer[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]command [color=#2f4f4f]"_.LAYER"[/color] [color=#2f4f4f]"_M"[/color] ATOLayer [color=#2f4f4f]""[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.LAYER"[/color] [color=#2f4f4f]"_ON"[/color] ATOLayer [color=#2f4f4f]"_T"[/color] ATOLayer [color=#2f4f4f]"_S"[/color] ATOLayer [color=#2f4f4f]"_C"[/color] ATOLayerColor ATOLayer [color=#2f4f4f]"_LT"[/color] ATOLineType ATOLayer [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]progn [b][color=MAROON]([/color][/b]initget 6[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq WindowLength [b][color=GREEN]([/color][/b]getdist [color=#2f4f4f]"\nEnter Window Length in feet: "[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]initget 7[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq WindowWidth [b][color=MAROON]([/color][/b]getdist [color=#2f4f4f]"\tWidth in feet: "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq RealArea [b][color=MAROON]([/color][/b]* WindowLength WindowWidth[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq WindowArea [b][color=MAROON]([/color][/b]strcat [b][color=GREEN]([/color][/b]rtos RealArea 2 2[b][color=GREEN])[/color][/b] [color=#2f4f4f]"SF"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]initget 1[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq ipt [b][color=MAROON]([/color][/b]getpoint [color=#2f4f4f]"\nInsert Point: "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]command [color=#2f4f4f]"_.INSERT"[/color] ATOBlkWPath ipt [b][color=MAROON]([/color][/b]getvar [color=#2f4f4f]"Userr3"[/color][b][color=MAROON])[/color][/b] [color=#2f4f4f]""[/color] [color=#2f4f4f]""[/color] [b][color=MAROON]([/color][/b]rtos WindowLength 2 2[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]rtos WindowWidth 2 2[b][color=MAROON])[/color][/b] WindowArea[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [color=#8b4513]; [b][color=FUCHSIA]([/color][/b]c:utility-end[b][color=FUCHSIA])[/color][/b][/color] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David awindow.dwg Quote Link to comment Share on other sites More sharing options...
asos2000 Posted June 5, 2010 Share Posted June 5, 2010 I think that ENTMAKE is better than calling command attached - The block creating lisp you can use as a subroutine - The lisp which I an useing to create. ATTR-WINDOW.lsp EntMaker CAB 03- MakeEntmake.lsp Quote Link to comment Share on other sites More sharing options...
CHLUCFENG Posted June 6, 2010 Author Share Posted June 6, 2010 Thanks David for adressing the code. It works as I had planned. I am comparing to my code to understand my errors. I tried using underscore insert, and underscore dot insert on my code and still kept getting errors. The underscore makes a command transparent correct? What does the underscore dot do? Thanks asos2000 for your ENTMAKE version. Although I have read through the code, I do not fully understand it. Pretty advanced stuff for me. I will use this code as a learning tool to understand the ENTMAKE ommand. Chuck Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 7, 2010 Share Posted June 7, 2010 The problem is in the ATTDEFs. With the verification bit set, you would need to feed the attribute values twice to the command call _. Means to use the international name and to ignore undefined commands. The - ( dash ) usually means to bypass the dialog box input screen. -David 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.