Can someone's help me to correct it,my formula in array,thanks a lot for help Best regards Ade Suharna ; Ac is stand for Array Circle ; Design by Ade Suharna ; May 11, 2004 (defun c:ac () (command "setvar" "cmdecho" "0") ;---------------------------------------------------- (setq loc (getpoint "\nCLICK LOCATION FOR OBJECT: ")) (setq cir (getreal "\nENTER RADIUS OF CIRCLE: ")) (setq qua (getreal "\nENTER NUMBER OF CIRCLE: ")) (setq col (getreal "\nENTER DISTANCE OF COLUMN: ")) (setq row (getreal "\nENTER DISTANCE OF ROW: ")) ;---------------------------------------------------- (setq sel1 (list (+ (car loc) col)(+ (cadr loc) row))) (setq sel2 (list (- (car loc) col)(- (cadr loc) row))) ;---------------------------------------------------- (command ".circle" loc cir "") (command ".array" "r" "w" sel1 sel2 qua qua col row "") ; = = = > problem here ;---------------------------------------------------- (command "setvar" "cmdecho" "1") (princ) )
Looks like you don't have a selection set for the Array command, but your "r" for Rectangular is coming where the command is asking you to Select objects, which means it will be expecting you to Remove objects from the selection set that doesn't exist yet. Try something like: (command ".array" "l" "" "r" ... Always check exactly what the command prompt sequence is. Without trying it out, I think you're giving it both column and row distances AND a "window" definition of the same thing (if that's what your "w" is for, but that's not a valid option after specifying the type of array). But you don't want to use both ways of giving it the distances. And it asks for number of columns and rows before it asks for the distances (whether by numbers or picking), but you appear to be trying to give it a "window" first. Maybe something like: (command ".array" "l" "" "r" qua qua row col) [to give it numerical distances, in which case you don't need to use the "sel1" and "sel2" at all] or (command ".array" "l" "" qua qua sel1 sel2) [to pick the distances "on-screen"] It asks for number of rows, and distance between rows, before columns, so your .... col row ... are in the wrong order. And you don't need the last "" in there. Also, in 2004, Array uses a dialog box, so if you're using that or 2005, make it the pre-hyphenated -array. But if you're going to answer all these prompts anyway, you don't need to write a routine to ask the user for them. The array command will do it for you. You could probably just do: (command "-array" "l" "" "r") and let the prompts take over from there, though maybe that doesn't work in a defun-ed command. It certainly would work in a macro or script. Kent Cooper, AIA
Hi Kent,I want ask you 1.What meaning "l" in (command ".array" "l" "" "r" qua qua sel1 sel2) 2. Why "qua" not active 3. Why "x" display,this here I want disappear(not display) Thanks for your reply Command: 'VLIDE CLICK LOCATION FOR OBJECT: ENTER RADIUS OF CIRCLE: 1 ENTER NUMBER OF CIRCLE: 10 ENTER DISTANCE OF COLUMN: 5 ENTER DISTANCE OF ROW: 5 Unknown command "VLIDE". Press F1 for help. Requires an integer between 1 and 32767. Enter the number of rows (---) <1>: 10 ;=====>"x" Enter the number of columns (|||) <1> 10 Enter the distance between rows or specify unit cell (---): 5 Specify the distance between columns (|||): 5
Why going thru the hard-time coding this while autodesk already has a fine array-routine build in autocad (from rel2000 and up) ? Jan
1.What meaning "l" in (command ".array" "l" "" "r" qua qua sel1 sel2) It should be typed as L it is for last , it is the LAST drawn entity , which in this case is tehe circle. 2. Why "qua" not active it is a snap mode you need to do this (setvar "osmode" 16) ; it is the numeric value for QUA osnap 3. Why "x" display,this here I want disappear(not display) It is a X or is the grip or best a + shown???
Hi ADE , it how I solve it ; Ac is stand for Array Circle ; Design by Ade Suharna ; May 11, 2004 (defun c:ac () (setvar "cmdecho" 0) ;---------------------------------------------------- (setq loc (getpoint "\nCLICK LOCATION FOR OBJECT: ")) (setq cir (getreal "\nENTER RADIUS OF CIRCLE: ")) (setq qua (getint "\nENTER NUMBER OF CIRCLE: ")); qua shall be a inters (setq col (getreal "\nENTER DISTANCE OF COLUMN: ")) (setq row (getreal "\nENTER DISTANCE OF ROW: ")) (command ".circle" loc cir ) (command ".-array" "L" "" "r" qua qua row col ) ;no more problem here ;; "L" stand for Last , or the last enty made , the circle in this case ;; "" an Enter to End teh selction of object ;; qua shall be entered twice it is the Row number and Col number ;; row = the row distance ;; col = the col distnace ;---------------------------------------------------- (setvar "cmdecho" 1) (princ) )
Thanks a lot devitg,now I understand it,yes I wrong write setvar,computer become confuse to run it. which in this case is tehe circle.
I can see that the computer might get confused. With "qua" in the line: (setq qua (getreal "\nENTER NUMBER OF CIRCLE: ")) I assumed it stood for "quantity" of rows and columns, and hadn't noticed it was the same as one of the Osnap mode abbreviations. Then with the creation of the array, you had [with subsequent adjustments]: (command ".array" "l" "" "r" qua qua sel1 sel2) Inside a (command) function, anything that operates as if you were typing it from the keyboard would be in quotation marks. Anything that isn't should be evaluated as a quantity or variable. So in theory, I would have thought that this would work, evaluating qua to the value set for it in the (setq) function above. And that would be appropriate, answering the prompts in the array command at that point. It should not be trying to read that as an Osnap call for a quadrant point, because if that's what you were trying to do, you should put them in quotation marks, and that wouldn't be the right kind of input at that point, anyway. But maybe there's a way that it would confuse them, and in general, it's good practice to not give names to (setq) variables that are the same as other system variables, or command names, or whatever. Kent Cooper, AIA ...
Thanks a lot to Kent Cooper,devitg,autodes and special thank for my best friend "Marius"or"naujoke",this problem only in "getreal" ,it's indicate that my knowledge on "getxxx" still small. Best regards Ade Suharna ; Ac is stand for Array Circle ; Design by Ade Suharna ; May 11, 2004 (defun c:ac () (command "setvar" "cmdecho" "0") (command ".limmax" (list 120 80)) ;---------------------------------------------------- (setq loc (getpoint "\nCLICK LOCATION FOR OBJECT: ")) (setq cir (getreal "\nENTER RADIUS OF CIRCLE: ")) (setq num (getint "\nENTER NUMBER OF CIRCLE: ")) ; this here problem last time "getreal" (setq col (getdist "\nENTER DISTANCE OF COLUMN: ")) ; this here problem last time "getreal" (setq row (getdist "\nENTER DISTANCE OF ROW: ")) ; this here problem last time "getreal" ;---------------------------------------------------- (setq sel1 (list (+ (car loc) col)(+ (cadr loc) row))) (setq sel2 (list (- (car loc) col)(- (cadr loc) row))) ;---------------------------------------------------- (command ".circle" loc cir "") (command ".array" "w" sel1 sel2 "" "r" num num row col"") ;---------------------------------------------------- (command "setvar" "cmdecho" "1") (princ) ) Hi Ade, Nice to hear from you that you're OK. I am fine too. When you use ARRAY command you need to define the number of columns and rows. It should be an integer number. So your problem should disappear if you set a variable NUM as follows: (setq NUM (GETINT "\nENTER NUMBER OF CIRCLE: ")) Best regards, my friend Marius