duanuys Posted April 8, 2014 Posted April 8, 2014 Here is my section of code that I need help on. The error VisualLISP is giving me is :Function Canceled. The builder doesn't complain, so my syntax is correct, but its just not working. I am making simple lines and changing the color to them using the "change" command with a function call. Can anyone please tell me what I am doing wrong?? Also just fyi in defun c:wellplace.. i just used the line (color po2) because i don't want to post the whole code in, everything else works fine, but breaks when it gets to that line. (defun color (col) (command "change" col "" "P" "C" "T" "255,0,0" "") ) (defun c:wellplace () (color po2) ;po2 is a "point number 2" that is calculated else in the code. ) Shouldn't it take the po2 which is a polar point, consisting of x,y,z coordinates and pass it along to the "color function"? I am doing this, because I need to do the "change" command a good 8 times, and i don't want 8 of duplicate lines of the same thing. Also if i go with not defining a function and just inputting the "change" command right into the body of my code, it works perfect, and replace 'col' with 'po2' so what gives? Quote
Hippe013 Posted April 8, 2014 Posted April 8, 2014 You may want to just post all of your code. It would certainly be easier for others to help narrow down where the error is occurring. Plus others may suggest other ways to accomplish what it is that you are trying to accomplish. Would love to help out more. regards, Hippe013 Quote
duanuys Posted April 8, 2014 Author Posted April 8, 2014 Sure thing alright here is the entire code so far.. isn't much to look at but I am a beginner. (defun dtr (x) (* pi (/ x 180.0)) ) (defun color (col) (command "change" col "" "P" "C" "T" "255,0,0" "") ) (defun c:wellplace (/ error pgas_redo poil_redo scale edge choice another hw po1 po2) (setq scale (getdist "\nThe scale of the map is 1in = ")) (setq edge (/ scale 20366.59)) (while (/= error 1) (setq redo 0) (setq another 0) (setq choice(getdist "\nChoose: Oil (1) , Gas (2) , Water (3) , Dry Hole (4) , Finished (5)")) (cond ((= choice 1) (while (/= redo 1) (prompt "\nYou have chosen Oil") (setq po1 (getpoint "\nPick well location.")) (setq po2 (polar po1 (dtr 90.0) edge)) (command "circle" "2p" po1 po2) (setq hw (polar po2 (dtr 270.0) (/ edge 2))) (command "-hatch" hw "P" "S" "CO" "T" "80,180,75" "" "") (setq another(getdist "\nCreate another? (1)YES or (2)NO")) (if (= another 2) (setq redo 1) (prompt "\nDrawing another Oil Well..")) ) ) ((= choice 2) (prompt "\nYou have chosen Gas") (setq po1 (getpoint "\nPick well location.")) (setq po2 (polar po1 (dtr 90.0) edge)) (command "circle" "2p" po1 po2) (color po2) ;(command "change" po2 "" "P" "C" "T" "255,0,0" "") (command "line" (polar po1 (dtr 360.0) edge)) ) ((= choice 5) (setq error 1) (alert "\nThank you for using Naud Inc Software.") ) (T(prompt "\Unknown Selection Please try again.")) ) ) ) Quote
rkmcswain Posted April 8, 2014 Posted April 8, 2014 I'm confused about this --> "Shouldn't it take the po2 which is a polar point, consisting of x,y,z coordinates and pass it along to the "color function"? It sounds like you are trying to pass the color command a list of XYZ coordinate? For the record this works fine, when po2 is an entity. (defun color (col) (command "change" col "" "P" "C" "T" "255,0,0" "") ) (defun c:wellplace () (setq po2 (car (entsel))) (color po2) ;po2 is a "point number 2" that is calculated else in the code. ) Quote
duanuys Posted April 8, 2014 Author Posted April 8, 2014 All i did is after creating a circle, i use the change command to change its color to red. the po2 is a point that happens to fall right on the circle. The "change" command works perfectly and exactly how it should when i place the entire thing in the code, you can see the original because i commented it. Then i tried the same thing but with a function call as i am going to have to use that change command like 8 times. Quote
Hippe013 Posted April 8, 2014 Posted April 8, 2014 A couple of things: 1. Don't use getdist to get a choice from the user. (Use getdist to get a distance from the user.) Look into initget and getkword. You'll be happy with the results. Or at the very least use getint. 2. I would create my circle using the 'addcircle method. (I can help you implement this) This will return your circle as a vla-object. That way you can change the color with a simple code such as: (vlax-put-property mycircle 'Color acred) mycircle being the circle object returned from 'addcircle method. 3. Don't use getdist to get a choice from the user. See note#1. regards, Hippe013 Quote
duanuys Posted April 8, 2014 Author Posted April 8, 2014 Awesome thankyou! I will go fix that, the program does run wierd at times, sometimes running smoothly then just breaking at wierd places.. it could be those simple things.. I would enjoy you helping me implement the addcircle method, please. Because Whatever I am doing its not working lol Quote
BIGAL Posted April 9, 2014 Posted April 9, 2014 Another way did not checkcode to carefully but if circle is last object drawn use (setq obj (entlast)) (command "change" obj "" "P" "C" "T" "255,0,0" "") ; if not last then just add the entlast line anyway after creating the circle Quote
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.