Jump to content

Recommended Posts

Posted

Hey guys, I have something like this. A simple dialogue where the user enters some dimensions and when the user clicks ok, a simple drawing is displayed.

The problem is that the location of the drawing is provided by the user by means of a click inside the drawing space, and the rest of the points are determined by their relationship with the given point.

The code that gives me the error is listed bellow, and the problem is Autocad doesn't prompt the user to give the point p0. So it considers it nil and then it crashes the execution.

 

(setq hGrinda (atoi hGrinda1)
)
(setq bGrinda (atoi bGrinda1)
)
(setq hReaz   (* 0.3 hGrinda)
)
(progn
   (setq p0 (getpoint)
   )
   ;***********************************
   (setq p1 (polar    p0 (dtr    270.0) hGrinda)
   
   )
   (setq p2 (polar    p1 (dtr    0.0) bGrinda)
   
   )
   (setq p3 (polar    p2 (dtr    90.0) (- hGrinda hReaz))
   
   )
   (setq p4 (polar    p3 (dtr    0.0) hReaz)
   
   )
   (setq p5 (polar    p4 (dtr    90.0) hReaz)
   
   )
   (setq pC0 (polar    p4 (dtr    90.0) (- (/ hReaz 2) (/ hReaz 5.0) ))
   
   )
   (setq pC1 (polar    pC0 (dtr 45.0) (* (/ hReaz 5.0) (sqrt 2.0)))
   
   )
   
   (setq pC2 (polar    pC1 (dtr 180.0)  (* 2.0 (/ hReaz 5.0)))
   
   )
   (setq pC3 (polar    pC2 (dtr 45.0) (* (/ hReaz 5.0) (sqrt 2.0)))
   
   )    
)

Posted

My suggestion is to add a prompt to your GETPOINT call – this way the user will be able to understand when is asked to input the point:

 

(getpoint "\nInsertion point: ")

 

Also, make sure that hGrinda1 and bGrinda1 variables have values (strings) when your run this piece of code.

I those conditions are meet the code runs OK for me.

 

Just curiosity, from where are you posting from?

 

Regards,

Posted

Hello,

Although that I do not know what does it mean this Lisp but here is the modification.

So if this does not suite your needs, you can show us the pose of the Lisp which is going to be to help us to help you back.

(defun c:axx ( / hGrinda bGrinda hReaz p0 p1 p2 p3 p4 p5 pc0 pc1 pc2 pc3)
(setq hGrinda (getint"\nenter hGrinda Number:"))
(setq bGrinda (getint"\nEnter bGrinda Number:"))
(setq hReaz (* 0.3 hGrinda))
(setq p0 (getpoint"\nSpecify a point:"))
;***********************************
(setq p1 (polar p0 (dtr 270.0) hGrinda))
(setq p2 (polar p1 (dtr 0.0) bGrinda))
(setq p3 (polar p2 (dtr 90.0) (- hGrinda hReaz)))
(setq p4 (polar p3 (dtr 0.0) hReaz))
(setq p5 (polar p4 (dtr 90.0) hReaz))
(setq pC0 (polar p4 (dtr 90.0) (- (/ hReaz 2) (/ hReaz 5.0) )))
(setq pC1 (polar pC0 (dtr 45.0) (* (/ hReaz 5.0) (sqrt 2.0))))
(setq pC2 (polar pC1 (dtr 180.0) (* 2.0 (/ hReaz 5.0))))
(setq pC3 (polar pC2 (dtr 45.0) (* (/ hReaz 5.0) (sqrt 2.0)))
) 
 (command "_pline" p1 p2 p3 p4 p5 pc0 pc1 pc2 pc3 "")
 (princ))
(defun DTR (ang)(* pi (/ ang 180.0)))

 

Tharwat

Posted

(setq hGrinda (getint"\nenter hGrinda Number:"))

(setq bGrinda (getint"\nEnter bGrinda Number:"))

 

Tharwat

 

There is no need for command prompt inputs since the OP stated that he/she have a dialog box for that (not included in code excerpt); for this reason there are those string conversion statements in original post.

 

Regards,

Posted

Thanks Mr.msasu.

 

But I think it is better to provide the DCL Functions in the code as well to know what to do.

 

In regard to:

(setq hGrinda (atoi hGrinda1)

)

it has to be like this :

(setq hGrinda (gettile \"hGrinda1\"))

 

And so on.

Tharwat

Posted

I kinda solved the problem, it's not quite perfect, but for now it works. Instead of prompting the user for that point after he clicks ok, he is now prompted before the dialogue loads. And now it works ok.

I'm guessing it's something weird on my end, because the same code, on another pc running autocad 2008 (i'm on autocad 2004) works.

And i'm posting from Bucharest.

Posted

Sound good that you have solved your issue. Regarding the fact that a routine doesn’t work on some stations, usually this is because of the local AutoCAD environment (system variables) and also drawing’s namespace (user routines and variables available).

 

And i'm posting from Bucharest.

I was sure that you are Romanian because of the naming of your variables: Grinda = Beam and Reaz(em) = Bearing.

 

Regards,

  • 8 years later...
Posted

I'd like to bump this topic up...  I find it sad that none of the responses even attempts to solve the OP's question.  He clearly states that he's using a dcl dialog to ask the user for a point on the dwg and a couple of values, but the (getpoint) in his lisp is not allowing the user to select a point...thus his value "p0" is nil, causing the rest of his lisp to crash because it's expecting "p0" to contain coordinates for a point.

 

I'm having the same problem.

 

I have dcl that gives the user a list of options in a complex lisp routine.  The dcl is NOT the problem, as the dialog displays correctly.

 

One of the dcl buttons is "Select a Point".  When that button is pressed, I call (done_dialog) then a lisp subroutine ("GetLap") and that subroutine contains the line:

(setq tmpPoint (getpoint "\nSelect a point:"))

"tmpPoint" is then used to as a base point to calculate other points, etc.

 

The subroutine will not prompt the user to select a point.  When I step thru the code, that line is evaluated but "tmpPoint" is never set because the code does not pause to display the (getpoint) prompt and, thus, allow the user to select a point.

 

If I run the "GetLap" manually (not via the dcl lisp routine), the "GetLap" works perfectly...so it's NOT an issue with "GetLap".  It has to be an issue with calling "GetLap" from the "Select a Point" action_tile.

Here is that line:

(action_tile "EndLap" "(done_dialog) (GetLap)")

 

(defun GetLap ()

 (setq TmpPt (getpoint "\nSelect Point:"))

 ;;;do other stuff;;;

)

Posted

If you post your full code I'm sure someone can help you.

Posted (edited)
7 hours ago, IndyRich said:

Here is that line:

(action_tile "EndLap" "(done_dialog) (GetLap)")

 

(defun GetLap ()

 (setq TmpPt (getpoint "\nSelect Point:"))

 ;;;do other stuff;;;

)

 

(GetLap) never happens because (done_dialog) returns control to the (start_dialog) statement. It is similar to a goto statement in basic.

 

(done_dialog) found  HERE

 

Example sequence

 

    (action_tile "cancel" "(done_dialog 0)");; This returns 0 to start_dialog. Anything after the (done_dialog [status]) is never evaluated 
    (action_tile "pick" "(done_dialog 2)")  ;; This returns 2 to start_dialog
  
    (setq exit_val (start_dialog))	
    (cond ( (= exit_val 2)
 	    (setq TmpPt (getpoint "\nSelect Point:"))
	    ;;;do other stuff;;;
          )
    );end_cond

 

You control what is returned to start_dialog. If your lisp program is a river (GetLap) is an Ox Bow Lake, not accessable and cut off from the river.

Edited by dlanorh
  • Like 1
Posted

Maybe a, not tested.

(done_dialog)(unload_dialog dcl_id)(getlap) 

 

Posted

Thanks, dlanorh!  Your explanation is greatly appreciated - and I appreciate your analogy!

 

I'm very new to dcl (in fact, this is my "dipping my toe into the water" endeavor), and I wasn't really clear on the difference between done_dialog and unload_dialog.  I assumed that done_dialog just "hid" the dialog so other code could run.

 

You corrected my course and provided a valuable tidbit of information.  Have a great day!!

 

BigAl,

I can see how that may work, too.  In my specific case, my dialog is prompting the user for several options.  I'm passing a different integer to start_dialog and using a cond to determine which function to run.  Since I'm very early in the learning curve, I'll try to test your idea later today or tomorrow and get back to you.  I like knowing as many different ways to accomplish the same result as possible - it keeps options open...as well as keeping your mind open to "the big picture".

Posted

No problem. If you need to hide a dcl form to make a selection ( a point, the color dialog etc) that is also possible.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...