Jump to content

Generate Bearings & Distances into table


oliver

Recommended Posts

Ahh, OK. The last time I worked anywhere that used Vanilla AutoCAD, I was 18 and it was r2000.

Not to give away my age, But I started with V2.6. I do not remember what it cost then, But I am sure it had to be much cheaper. It was purchased by the company I worked for. The first version I purchased for myself was release 9 which I believe was about $3000 US dollars then and when I upgraded to release 10, The upgrade charge was about $500. I did not upgrade again till AutoCAD 2000 was available. It did not seem worth it for all the small changes you were getting with each new release.

Link to comment
Share on other sites

  • Replies 75
  • Created
  • Last Reply

Top Posters In This Topic

  • Madruga_SP

    22

  • ymg3

    14

  • fixo

    9

  • alanjt

    8

Top Posters In This Topic

Posted Images

Not to give away my age, But I started with V2.6. I do not remember what it cost then, But I am sure it had to be much cheaper. It was purchased by the company I worked for. The first version I purchased for myself was release 9 which I believe was about $3000 US dollars then and when I upgraded to release 10, The upgrade charge was about $500. I did not upgrade again till AutoCAD 2000 was available. It did not seem worth it for all the small changes you were getting with each new release.

Yeah, the only reason I knew then was because my Dad owned the company and I asked him. I only know now because I'm when I new release arrives, it's placed on my desk and the amount is inside.

Link to comment
Share on other sites

Yeah, the only reason I knew then was because my Dad owned the company and I asked him. I only know now because I'm when I new release arrives, it's placed on my desk and the amount is inside.

I am not sure about this, But If you currently have vanilla CAD and wanted to added on a Third Party Package of sorts, Would you need to pay the full price for the add-on or would there be a small upgrade fee. If there is a small additional fee to pay, I do not know why people would groan over it. It seems to me getting the software specific to your discipline would be worth the small fee to pay. On the other hand customizing AutoCAD to your specific discipline would be worth the while in learning an API that would suit your needs. It also seems like people groan over that one as well. Just hand over the free goods and do it exactly to my specifications. I would say there is something wrong with that, But others feel its justified. Then you end up marrying the code you provided.

Link to comment
Share on other sites

I am not sure about this, But If you currently have vanilla CAD and wanted to added on a Third Party Package of sorts, Would you need to pay the full price for the add-on or would there be a small upgrade fee. If there is a small additional fee to pay, I do not know why people would groan over it. It seems to me getting the software specific to your discipline would be worth the small fee to pay. On the other hand customizing AutoCAD to your specific discipline would be worth the while in learning an API that would suit your needs. It also seems like people groan over that one as well. Just hand over the free goods and do it exactly to my specifications. I would say there is something wrong with that, But others feel its justified. Then you end up marrying the code you provided.

I'll say that I can't imagine having to do engineering without Land Desktop/Civil 3D or the like. I wouldn't work for a company that expected results with only Vanilla.

Link to comment
Share on other sites

I'll say that I can't imagine having to do engineering without Land Desktop/Civil 3D or the like. I wouldn't work for a company that expected results with only Vanilla.

True, But there are some frugal companies out there. Penny wise and dollar foolish.

Link to comment
Share on other sites

  • 2 years later...

Hi all,

It's my first post in this excellent forum.

 

I've tested this code and it is just awesome, congratulation guys!

I'd like to change the bearings by azimuth, because I don't use bearings.

 

I'll be really appreciated if someone help me out.

 

Thank in advance!

:D

Link to comment
Share on other sites

Hi all,

It's my first post in this excellent forum.

 

I've tested this code and it is just awesome, congratulation guys!

I'd like to change the bearings by azimuth, because I don't use bearings.

 

I'll be really appreciated if someone help me out.

 

Thank in advance!

:D

Hi Madruga_SP, welcome on board !

Try this revisited code,

but I don't know much about azimuth so maybe

there is a mistake in my math, check them by yourself

on working template

 
;;;----------------------------------- start of code ---------------------------;;;
;; azt.lsp
;; started by fixo, updated by SmallFish
(vl-load-com)
(defun C:AZT (/ *error* acsp  az atable cnt col dist item osm
                     point_list pt row table_data tmp tmp_data
             degreeloc minuteloc secondloc AngString)

  (defun *error*  (msg)
    (if (and msg
      (not
        (member msg
         '("console break" "Function cancelled" "quit / exit abort"))))
      (princ (strcat "\nError: " msg))
      )
    (if osm
      (setvar "osmode" osm))
    (princ)
    ) 
; Get azimuth by angle value
(defun _azimuth (ang / )
; Convert value in radians to degrees
(defun rtd (a) (* 180.0 (/ a pi)))
(cond ((= ang 0) 90.0)
((< 0  ang  (/ PI  2)) (- 90.0  (rtd ang)))
((= ang  (/ PI  2)) 0.0) 
((< (/ PI  2) ang  PI)(+ (rtd ang) 180.0)) 
((= ang  PI) 270.0)
(( < PI  ang  (* PI  1.5)) (rtd ang))
((= ang  (* PI  1.5)) 180.0)
((< (* PI  1.5)  ang  (* PI  2))(- (rtd ang)  180.0))
((= ang  (* PI  2)) 90.0))
 )

(setq osm (getvar "osmode"))
(setvar "osmode" 1)

(setq cnt 1)
(while (setq pt (getpoint
    (strcat "\n  >> Specify point #"
     (itoa cnt)
     " by order (hit Enter to exit) >> ")))
  (setq point_list (cons pt point_list)
 cnt    (1+ cnt))
  )
(setq point_list (reverse point_list))

(setq cnt 0)
(while (<= cnt (- (length point_list) 2))
  (setq tmp  (list (strcat (itoa (1+ cnt)) " - " (itoa (+ cnt 2)))
         (nth cnt point_list)
         (nth (1+ cnt) point_list))
 tmp_data (cons tmp tmp_data)
 )
  (setq cnt (1+ cnt))
  )
(setq tmp      (list (strcat (itoa (length point_list)) " - 1")
       (last point_list)
       (car point_list))
      tmp_data (cons tmp tmp_data)
      )
(setq tmp_data (reverse tmp_data))

(foreach item  tmp_data
;(setq ang (angtos(angle (cadr item) (caddr item))4 2);precision 2 - minutes only
     (setq az (angtos (_azimuth (angle (cadr item) (caddr item))) 4 2)
      degreeloc (vl-string-position (ascii "d") az);location of "d"
      minuteloc (vl-string-position (ascii "'") az);location of '
;;;       secondloc (vl-string-position (ascii "\"") ang);location of "
);setq
(if (= (- minuteloc degreeloc) 2)
(setq az (vl-string-subst "d0" "d" az));add 0 for seconds under 10
);if
;;; (if (= (- secondloc minuteloc) 2)
;;; (setq ang (vl-string-subst "'0" "'" ang));add 0 for minutes under 10
;;; );if
(setq AngString (vl-string-subst "°" "d" az);Substitute degree symbol
      dist (distance (cadr item) (caddr item))
      dist (strcat (rtos dist 2 2) " m.")
      tmp (list (car item) AngString dist)
      table_data (cons tmp table_data)
);setq
);foreach

(setq
       table_data (reverse table_data)
       pt (getpoint "\n  >> Specify insertion point >> ")
       acsp (vla-get-block
            (vla-get-activelayout
            (vla-get-activedocument
            (vlax-get-acad-object))))

      atable (vlax-invoke acsp 'AddTable pt
             (+ 2 (length table_data))
             (length (car table_data))
             (* (getvar "textsize") 2.0)
             (* (getvar "textsize") 15))   
);setq
(vla-put-regeneratetablesuppressed atable :vlax-true)
(vla-settextheight atable actitlerow (getvar "textsize"))
(vla-settextheight atable acheaderrow (getvar "textsize"))
(vla-settextheight atable acdatarow (getvar "textsize"))
(vla-put-vertcellmargin atable (/ (getvar "textsize") 4.25))
(vla-settext atable 0 0 "TECHNICAL DESCRIPTIONS")
(vla-settext atable 1 0 "LINES")
(vla-settext atable 1 1 "AZIMUTH")
(vla-settext atable 1 2 "DISTANCES")
(setq row 2)
(foreach item  table_data
  (setq col 0)
  (foreach x  item
    (vla-settext atable row col x)
    (vla-setcellalignment atable row col acMiddleCenter)
    (setq col (1+ col)))
  (setq row (1+ row))
  )

  (vla-put-regeneratetablesuppressed atable :vlax-false)

  (*error* nil)

  (princ)
)
(prompt "\n\t---\tStart command with \"AZT\"\t---")
(prin1)
(or(vl-load-com)(princ))
;;;----------------------------------- end of code ---------------------------;;;

Link to comment
Share on other sites

Hi fixo,

Thanks for the quick replay.

 

I don't Know how can I explain better what azimuth is, my english is poor.

 

But I configure autocad, in drawing units angle type Deg/Min/Sec - Precision 0°00'00"- Clockwise - Direction Control North.

 

e.g. azimuth 35°05'12" (without NE,SW)

 

Regards.

Link to comment
Share on other sites

Try this one very limited tested, check all values, I'm not sure

that all is correct in this code

 
;;;----------------------------------- start of code ---------------------------;;;
;; azt2.lsp
;; started by fixo, updated by SmallFish
(vl-load-com)
(defun C:AZT (/ *error* acsp ang az atable cnt col dist item osm
point_list pt row table_data tmp tmp_data)

(defun *error* (msg)
(if (and msg
(not
(member msg
'("console break" "Function cancelled" "quit / exit abort"))))
(princ (strcat "\nError: " msg))
)
(if osm
(setvar "osmode" osm))
(princ)
)


;Convert value in radians to degrees
(defun rtd (a) (* 180.0 (/ a pi))) ;_ end of defun
; Convert value in degrees to radians
(defun dtr (a)(* pi (/ a 180.0))) ;_ end of defun
;; degrees to DMS string
;; by VK (Vladimir Kleshev)
(defun gr->gms (a / g m s)
(setq g (rtos (fix a) 2 0))
(setq m (rtos (fix (* (setq a (- a (fix a))) 60)) 2 0))
(setq s (rtos (fix (* (- (* a 60) (fix (* 60 a))) 60)) 2 0))
(strcat g
"%%d "
(if (= (strlen m) 2)
m
(strcat "0" m)
) ;_ if
"' "
(if (= (strlen s) 2)
s
(strcat "0" s)
) ;_ if
"\""
) ;_ strcat
) ;_ defun
(setq osm (getvar "osmode"))
(setvar "osmode" 1)

(setq cnt 1)
(while (setq pt (getpoint
(strcat "\n >> Specify point #"
(itoa cnt)
" by order (hit Enter to exit) >> ")))
(setq point_list (cons pt point_list)
cnt (1+ cnt))
)
(setq point_list (reverse point_list))

(setq cnt 0)
(while (<= cnt (- (length point_list) 2))
(setq tmp (list (strcat (itoa (1+ cnt)) " - " (itoa (+ cnt 2)))
(nth cnt point_list)
(nth (1+ cnt) point_list))
tmp_data (cons tmp tmp_data)
)
(setq cnt (1+ cnt))
)
(setq tmp (list (strcat (itoa (length point_list)) " - 1")
(last point_list)
(car point_list))
tmp_data (cons tmp tmp_data)
)
(setq tmp_data (reverse tmp_data))



(foreach item tmp_data
(setq ang (angle (cadr item) (caddr item)))
; Get azimuth by angle value
(cond
((zerop ang)(setq ang (getvar "angbase"))) 
(( < 0 ang (/ pi 2))(setq ang (- (getvar "angbase") ang)))
(( < (/ pi 2) ang (* pi 1.5))(setq ang (+ (getvar "angbase")(- (* pi 2.) ang))))
(( < (* pi 1.5) ang (* pi 2.))(setq ang (+ (getvar "angbase")(- (* pi 2.) ang)))))

(setq az (gr->gms (rtd ang)))
(setq az (vl-string-subst "°" "%%d" az);Substitute degree symbol
dist (distance (cadr item) (caddr item))
dist (strcat (rtos dist 2 2) " m.")
tmp (list (car item) az dist)
table_data (cons tmp table_data)
)
)

(setq
table_data (reverse table_data)
pt (getpoint "\n >> Specify insertion point >> ")
acsp (vla-get-block
(vla-get-activelayout
(vla-get-activedocument
(vlax-get-acad-object))))

atable (vlax-invoke acsp 'AddTable pt
(+ 2 (length table_data))
(length (car table_data))
(* (getvar "textsize") 2.0)
(* (getvar "textsize") 15)) 
);setq
(vla-put-regeneratetablesuppressed atable :vlax-true)
(vla-settextheight atable actitlerow (getvar "textsize"))
(vla-settextheight atable acheaderrow (getvar "textsize"))
(vla-settextheight atable acdatarow (getvar "textsize"))
(vla-put-vertcellmargin atable (/ (getvar "textsize") 4.25))
(vla-settext atable 0 0 "TECHNICAL DESCRIPTIONS")
(vla-settext atable 1 0 "LINES")
(vla-settext atable 1 1 "AZIMUTH")
(vla-settext atable 1 2 "DISTANCES")
(setq row 2)
(foreach item table_data
(setq col 0)
(foreach x item
(vla-settext atable row col x)
(vla-setcellalignment atable row col acMiddleCenter)
(setq col (1+ col)))
(setq row (1+ row))
)

(vla-put-regeneratetablesuppressed atable :vlax-false)

(*error* nil)

(princ)
)
(prompt "\n\t---\tStart command with \"AZT\"\t---")
(prin1)
(or(vl-load-com)(princ))
;;;----------------------------------- end of code ---------------------------;;;

Link to comment
Share on other sites

Hi Mr. Fixo,

Thank you very much, worked like a charm.

I really appreciate your help, I'll be greatful forever!

Thanks for patience and kindness in help me out.

 

If you don't mind, I'd like to ask just one more thing, fixo.

Could you configure the table with 15 column and the sequencial line in horizontal, like the image bellow?

 

File attached

TABLE.jpg

 

Best Regards.

Link to comment
Share on other sites

  • 2 weeks later...

Hi Fixo,

I need a help to modify the azimuth table.

Would you mind help me out with my task, please?

 

I'd like the table formate like image on post#35.

 

Many Thanks!

Link to comment
Share on other sites

Hi Madruga_SP

I could not realize this part programmatically, sorry

I guess just one way to make this is go to table Properties window

then in the Break tabs set Enabled to Yes,

Spacing to 0 and manipulate with Break Height (me think set to 36 or 48)

After that you can delete the title row and then paste one

instead above the table, merge colums in thistitle row

and add your title text

Kind regards,

Cheers :)

Link to comment
Share on other sites

Hi Madruga_SP

I could not realize this part programmatically, sorry

I guess just one way to make this is go to table Properties window

then in the Break tabs set Enabled to Yes,

Spacing to 0 and manipulate with Break Height (me think set to 36 or 48)

After that you can delete the title row and then paste one

instead above the table, merge colums in thistitle row

and add your title text

Kind regards,

Cheers :)

 

No worries, Fixo

You already helped me a lot.

I'll try doing this through the Table Properties as you said.

 

Thanks anyway.

Best Regards

Link to comment
Share on other sites

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