Some people have seen portions of this Autolisp before. I solved one problem and encounter more as I progressed into the abyss of confusion. So here it goes! Some people have asked for me to post the whole Autolisp routine so suggestions can be made help improve what I am trying to accomplish. the specific problem I am having now is with the Array Command. I have had success with the command and it has performed without a hitch. I have since tweaked to routine and now it does not function as it is suppose to. So far the function works all the way through to the array and I get and error "invalid option keyword." (see screenshot). I changed the the array function to a suggestion given by a google search (how to get Autocad array function to work with lisp" the result kicked out by AI is where the command presently sits. I have tried several iteration of the array with mixed results (-array, _.array, _array, _arraypolar, etc). I was trying to find my last posting to find out if it was working then, but was unable to find it.
(command "-array" "l" "" "_p" "0,0" BH_qty "" "n") ; does not execute the command in the autolisp routine though it works when type directly into Autocad? The PNG can attest to the success of the command. If I can get the command (-array) to work when typed direcly into Autocad why does it not work with Autolisp in the same manor? This is why the confusion is racking my brain? The logic conflicts? Again, I appreciate any suggestions to help improve my commands.
I set this up to make the initial object at 0,0, but I would like to make this work at a selected point in the future. I welcome inputs in that regard as well. I also have some confusion about the local and global variables. My previous thoughts might be wrong in that line of thinking? I was under the impression the local variables (first row parenthesis) stays within the Baseringcmd function, once it's closed the variable reference drops?
(defun c:baseringcmd (/ OD ID BC HalfBC pt1 BHD thk)
(setq OD (getdist "\nSpecify base ring OD:"))
(command "_.circle" "0,0" "d" OD)
(setq Osdia (entlast))
(setq ID (getdist "\nSpecify base ring ID:"))
(command "_.circle" "0,0" "d" ID)
(setq ISdia (entlast))
(setq BC (getdist "\nSpecify bolt circle diameter:"))
(if BC
(progn
(setq halfBC (/ BC 2.0))
(princ (strcat "\nHalf the BC distance is: " (rtos halfBC)))
)
)
(setq pt1 (list 0.0 halfBC))
(setq BHD (getdist "\nSpecify bolt hole diameter:"))
(command "_.circle" pt1 "d" BHD)
(command "-view" "_swiso")
(setq BH_qty (getint "\nSpecify the number of bolt holes:")) ; Autodesk "Sea Haven" suggestion
(setq BHQ_Array (entlast))
(command "rotate" "l" "" "0,0" (/(/ 360 BH_qty) 2))
(if (= (tblsearch "layer" "Plate") nil)
(command "layer" "m" "Plate" "c" 204 "" "")
)
(command "chprop" OSdia "" "la" "Plate" "")
(command "layer" "s" "0")
(setq BH_array (ssget BHQ_array)
(if BH_array
(progn
(command "_array" BH_array "" "_p" "0,0" BH_qty "" "n")
)
(princ "\nNo objects selected.")
) ; end if
;(princ)
; recomendation from Autodesk "Kent1Cooper"
;(command "_.array" "_last" "" "_polar" boltcenter "_items" nbolt "")
;"BH_qty" for nbolt, does not type in Autocad
(setq thk1 (getdist "\nSpecify base ring thickness:"))
(command "_.extrude" OSdia ISdia BHQ_array "" thk1)
(Command "subtract" OSdia "" ISdia "") ; BHQ_Array "")
; (princ)
😉