Jump to content

Recommended Posts

Posted
When you use this system of entering angles, you are very careful to always use two digits for both the minutes and seconds.

 

So 45d3'5" would become 45.0305

 

You may have something there eldon.

  • Replies 46
  • Created
  • Last Reply

Top Posters In This Topic

  • pBe

    15

  • Madruga_SP

    14

  • hmsilva

    5

  • alanjt

    4

Top Posters In This Topic

Posted Images

Posted

Thanks all of you guys,

I really appreciate every help and suggestions.

 

But I still couldn't get a result that I want to. Sorry for my poor english, I know is hard to understanding my request.

 

The code bellow is a great code, is not mine. But I'd like to make it better.

Let me explain my request.

When I invoke the code, specify the start point, set the distance, angles write the polylines and press ENTER or ESC to cancel or finish the routine. (like a PLINE command).

 

  
Author: Rogério
Modificated by: Roy
(defun C:AZ ( / AZ_INPUT DISTANCIA GRAUS MINUTOS POINT OLDOSMODE SEGUNDOS)
    (setvar "cmdecho" 0)
    ;; In the original code the UNITS an INSUNITS commands are called last.
    ;; I believe it makes  more sense to call them first...
    (command
      "_.units" 2 2 2 4 270 "_no"  ; Decimal=2/ N°Casas=2/ Sistema Angulo=2/ Fração Angulo=4/ Direção Angulo=0/ Relógio=N
      "_.insunits" 0
    )
    (if
      (and
        (/= (setq DISTANCIA (getstring "\nDistância: ")) "") ; Strange to use (getstring) here.
        (/= (setq GRAUS (getstring "\nÂngulo: ")) "")        ; Id.
        (/= (setq MINUTOS (getstring "\nMinutos: ")) "")     ; Id.
        (/= (setq SEGUNDOS (getstring "\nSegundos: ")) "")   ; Id.
      )
      (progn
        (setq AZ_INPUT (strcat "@" DISTANCIA "<" GRAUS "d" MINUTOS "'" SEGUNDOS "\""))
        (princ (strcat "\nAzimute: " AZ_INPUT))
        (setq POINT (getpoint "\nPick o ponto de início:"))
        (setq OLDOSMODE (getvar "osmode"))
        (setvar "osmode" 0)
        (command "_.pline" POINT AZ_INPUT "")
        (setvar "osmode" OLDOSMODE)
      )
    )
    (setvar "cmdecho" 1)
    (princ)
   )

 

If anyone has a better idea or suggestion is very wellcome!:D

Thank in advance.

:thumbsup:

Posted

I'm sorry dude, I give up... :)

 

"Then I start back at one" ------ Brian McKnight

Posted
I'm sorry dude, I give up... :)

 

"Then I start back at one" ------ Brian McKnight

 

No problem dude.

Thanks anyway.

:thumbsup:

Posted

Dont fret Madruga_SP, help is just around the corner.... wait for it.....

Posted

Hi MAdruga,

if I understand correctly, maybe something like this...

[i hope Rogerio can forgive me]

 

Author: Rogério
Modificated by: Roy
Modificated by: hms
(defun C:AZ ( / AZ_INPUT DISTANCIA GRAUS MINUTOS POINT OLDOSMODE SEGUNDOS)
    (setvar "cmdecho" 0)
    ;; In the original code the UNITS an INSUNITS commands are called last.
    ;; I believe it makes  more sense to call them first...
    ;; Add a loop
    (command
      "_.units" 2 2 2 4 270 "_no"  ; Decimal=2/ N°Casas=2/ Sistema Angulo=2/ Fração Angulo=4/ Direção Angulo=0/ Relógio=N
      "_.insunits" 0
    )
    (if
      (and
        (/= (setq DISTANCIA (getstring "\nDistância: ")) "") ; Strange to use (getstring) here.
        (/= (setq GRAUS (getstring "\nÂngulo: ")) "")        ; Id.
        (/= (setq MINUTOS (getstring "\nMinutos: ")) "")     ; Id.
        (/= (setq SEGUNDOS (getstring "\nSegundos: ")) "")   ; Id.
      )
      (progn
        (setq AZ_INPUT (strcat "@" DISTANCIA "<" GRAUS "d" MINUTOS "'" SEGUNDOS "\""))
        (princ (strcat "\nAzimute: " AZ_INPUT))
        (setq POINT (getpoint "\nPick o ponto de início:"))
        (setq OLDOSMODE (getvar "osmode"))
        (setvar "osmode" 0)
        (command "_.pline" POINT AZ_INPUT "")
 (while
   (and
        (/= (setq DISTANCIA (getstring "\nDistância: ")) "") ; Strange to use (getstring) here.
        (/= (setq GRAUS (getstring "\nÂngulo: ")) "")        ; Id.
        (/= (setq MINUTOS (getstring "\nMinutos: ")) "")     ; Id.
        (/= (setq SEGUNDOS (getstring "\nSegundos: ")) "")   ; Id.
      )
   (setq AZ_INPUT (strcat "@" DISTANCIA "<" GRAUS "d" MINUTOS "'" SEGUNDOS "\""))
   (command "_.pline" (getvar "lastpoint") AZ_INPUT "")
   )
        (setvar "osmode" OLDOSMODE)
      )
    )
    (setvar "cmdecho" 1)
    (princ)
   )

 

hope that helps

Henrique

Posted

Henrique,

 

Can you make it in such a way you can type the angle values within a single prompt. [the way the OP wanted after Bigal suggested it]

 

command: AZ

Distance: 40

Azimuth: 12.5635

 

or

 

Distance: 40

Azimuth: 12.0506;

 

Your modification use the concatenated string to feed as value on pline command. Which you can easily work out using the single value as shown above. A decimal equivalent of the compass reading for input.

 

I have not yet wrapped my head on Bigals formula for decimal angle

 

A suggestion 123.45'57" enter as 123.4557

Fix 123.4557 = 123 degrees

rem = .4557 * 100 =45.57 fix again = 45 minutes

rem = .57 *100 = seconds

angle = deg+min/60+sec/3600

convert all to decimal angle and use in polar function for next point

 

Thank you for helping out Henrique.

Posted

Hi pBe,

 

My post was only to try to understand if this is the correct direction that Madruga want to the code...

If so, redesigning the code and incorporate Bigals suggestion, makes much more sense, to me, than ask to the user to provided values to the code ​​as text strings...

Cheers

Henrique

Posted
Hi pBe,...

My post was only to try to understand if this is the correct direction that Madruga want to the code...

 

Fair enough. ;)

Posted
Henrique,

 

Can you make it in such a way you can type the angle values within a single prompt. [the way the OP wanted after Bigal suggested it]

 

command: AZ

Distance: 40

Azimuth: 12.5635

 

or

 

Distance: 40

Azimuth: 12.0506;

 

Your modification use the concatenated string to feed as value on pline command. Which you can easily work out using the single value as shown above. A decimal equivalent of the compass reading for input.

 

I have not yet wrapped my head on Bigals formula for decimal angle

 

 

 

Thank you for helping out Henrique.

 

pBe,

I had not read this part

 

"I have not yet wrapped my head on Bigals formula for decimal angle"

 

with the testing purpose...

 

(setq a (getreal "\nBearing in Deg Mins Sec [DD.MMSS] : "));; <- 47.5603
(setq d (fix a));; -> 47
(setq m (fix (* 100 (- a d))));; -> 56
(setq s (* 100 (- (* 100 (- a d)) m)));; -> 3
(setq dec_deg (+ d (/ m 60.0) (/ s 3600.0)));; -> 47.9342
 
;; or

(setq dec_deg (+ d (/ (+ m (/ s 60)) 60)));; -> 47.9342

;; reverse test

(setq d_m_s (angtos (angtof (rtos dec_deg 2 4) 0) 1 4));; -> "47d56'3\""

 

Cheers

Henrique

Posted

Nice work Henrique :thumbsup:

 

Does that mean it could be as simple as this

 

(defun C:AZ (/ point ds a d m s dec_deg)
 (setvar "cmdecho" 0)
   (if (setq POINT (getpoint "\nPick o ponto de início:"))
     (progn
   	(command "_Pline" point)
    (while (> (getvar "CMDACTIVE") 0)	
	(if (and (Setq ds (getdist (getvar 'Lastpoint) "\nEnter Distance: "))
	         (setq a (getreal "\nBearing in Deg Mins Sec [DD.MMSS] : ")))
              (progn	
	      (setq d (fix a))
	      (setq m (fix (* 100 (- a d))))
	      (setq s (* 100 (- (* 100 (- a d)) m)))
	      (setq dec_deg (+ d (/ m 60.0) (/ s 3600.0)))
            [color="#8b0000"] [b] (command (strcat "@" (rtos ds) "<" (angtos (angtof (rtos dec_deg 2 4) 0) 1 4)))[/b][/color]
              )
          	(command "")
          )
      )
       )
     )
     (princ)
   )

 

or using polar

 

(defun C:AZ2 (/ point ds a d m s dec_deg)
 (setvar "cmdecho" 0)
   (if (setq POINT (getpoint "\nPick o ponto de início:"))
     (progn
   	(command "_Pline" point)
    (while (> (getvar "CMDACTIVE") 0)	
	(if (and (Setq ds (getdist (getvar 'Lastpoint) "\nEnter Distance: "))
	         (setq a (getreal "\nBearing in Deg Mins Sec [DD.MMSS] : ")))
              (progn	
	      (setq d (fix a))
	      (setq m (fix (* 100 (- a d))))
	      (setq s (* 100 (- (* 100 (- a d)) m)))
	      (setq dec_deg (+ d (/ m 60.0) (/ s 3600.0)))
             [b][color="blue"] (command (setq point (polar point (* pi (/ dec_deg 180.0)) ds)))[/color][/b]
              )
          	(command "")
          )
      )
       )
     )
     (princ)
)

 

I think between Bigal and Hmsilva suggestions, the OP will be satisfied with the solution. but then again.. maybe not. :)

Posted

pBe,

the first code works as it should, but there must be some pre configuration, all the variables that define the topography world... ;)

(command "units" 2 2 2 4 270 Y "insunits" 0)

As BIGAL wrote:

 

"If doing change units in other routines as well set up a preloaded defun so 1 line in your code in Civil stuff used all the time."

 

The second code, will give error, because we have to fix the angles, depending on the quadrant in which they are, because autocad measures the angles in radians and the direction is anti clockwise, and we are drawing in clockwise direction, and angbase is not the same, so will be need a lot more code, to achieve the same result as the first code...

I hope that the OP will be satisfied with the first solution...

 

Cheers

Henrique

Posted

Many Thanks, guys!!!

:D

 

Really good solution, I'm very pleased with the goals.

I'm really appreciate the help.

 

The code on post #31 by pBe.

It giving a strange solution. I've attached the dwg file to explain better my request.

 

AZ-AUTOLISP.dwg

 

Best Regards

Posted

Hi Madruga,

 

the az code works as it should, the problem is Object Snap, set "osmode" to 0...

 

Henrique

Posted
Hi Madruga,

 

the az code works as it should, the problem is Object Snap, set "osmode" to 0...

 

Henrique

 

Add "_non" in the command, before the direction/length call.

Posted

:thumbsup:

 

Now the code works like a charm!

 

Thank you all of you!!!

:notworthy::notworthy::notworthy:

 

 

Best Regards

Posted
Just a one suggestion, azimuth has a different calcultation

for local settings,

see here for more (resolved by Stadler)

 

Thank you for the info Oleg, I'll have a look-see

 

...the first code works as it should, but there must be some pre configuration, all the variables that define the topography world... ;)

 

Why oh why did i remove that line in the first place. good catch Henrique

 

...the problem is Object Snap, set "osmode" to 0...

 

Correct.

 

Add "_non" in the command, before the direction/length call.

 

Even better.

 

Thank you all of you!!!

Best Regards

 

We are glad to be of service. Now if you can just wire the money to account # 1945..... just kidding :lol:

 

Cheers :beer:

Posted
We are glad to be of service. Now if you can just wire the money to account # 1945..... just kidding :lol:

Very funny pBe. If I had enough money, I would certainly pay back for the service.

But I'm poor guy.:cry:

 

I'm really satisfied with the code.

You are fantastic, guys!

 

God Bless you.

:D

Posted
Very funny pBe. If I had enough money, I would certainly pay back for the service.

But I'm poor guy.:cry:

 

Don't worry about it. We're just teasing you is all. :)

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