Jump to content

Recommended Posts

Posted

What is wrong with this code?

 

(setq pnt1 (getpoint "\nPoint 1"))
(setq pnt2 (getpoint "\nPoint 2"))
(setq disth (getdist '(pnt1 pnt2)))
(setq ncol (getint "\nNº Columns"))
(setq disth (/ disth ncol))

Posted

The GETDIST function allows you to get a distance dynamically on screen:

 

(if (setq pnt1 (getpoint "\nPoint 1"))
(setq disth (getdist pnt1 "\nPoint 2"))
)

 

To calcute distance between two point use DISTANCE:

 

(if (and (setq pnt1 (getpoint "\nPoint 1"))
        (setq pnt2 (getpoint "\nPoint 2")))
(setq disth (distance pnt1 pnt2))
)

 

Regards,

Mircea

Posted

Tanks Mircea,

However in the AutoCad Help these examples are presented:

 

(setq dist (getdist)) 
(setq dist (getdist '(1.0 3.5))) 
(setq dist (getdist "How far ")) 
(setq dist (getdist '(1.0 3.5) "How far? "))

Posted

getdist will prompt the user to pick one or two points and return the distance between them, it requires a string argument (prompt message) and optional base point for the distance - you are supplying it with a quoted list of two symbols.

 

Essentially, there are two ways you can approach this:

 

1) getpoint - getpoint - distance:

 

(setq p1 (getpoint "\nPoint 1: "))
(setq p2 (getpoint "\nPoint 2: "))
(setq di (distance p1 p2))

2) getpoint - getdist:

 

(setq p1 (getpoint "\nPoint 1: "))
(setq di (getdist p1 "\nDistance: "))

Note that both of the above solutions do not account for null user input and will require some error trapping in this respect.

Posted

Tanks, Lee.

In fact what I want is to use distance value as the value set by the input of points 1 and 2. I understand.

Posted
However in the AutoCad Help these examples are presented:

 

To match the help example you may write it like this:

(setq coordX (getreal "\nCoordinate X of point 1: ")
     coordY (getreal "\nCoordinate Y of point 1: "))
(setq disth (getdist (list coordX coordY) "\nInput second point:"))

For sure this isn't practical at all, is just to help you understand.

 

Regards,

Mircea

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...