Jump to content

Draw & Automaically Label Dist on Centerline Pts...


Recommended Posts

  • Replies 54
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    24

  • CAB

    18

  • JWeyer

    11

  • David Bethel

    1

Top Posters In This Topic

Posted Images

Posted

I take my hat off to you CAB, you never cease to amaze me :shock:

 

That "flag-maker" is brilliant codeing. --> I will learn from your posted codes - Thanks :)

Posted

cool routine alan and lee mac, you might like to add linetype maker for AG-CENTER because i still have to add it to make it work, just a suggestion...:-)

Posted
cool routine alan and lee mac, you might like to add linetype maker for AG-CENTER because i still have to add it to make it work, just a suggestion...:-)

 

 

Good Point Wizman, and thanks for your compliments. :) I suppose an addition of a linetype maker would make the routine "complete" so that anyone can dive right in and use it - but I suppose with this specialised usage, it may not be too necessary - see what Charles thinks.

Posted
Good Point Wizman, and thanks for your compliments. :) I suppose an addition of a linetype maker would make the routine "complete" so that anyone can dive right in and use it - but I suppose with this specialized usage, it may not be too necessary - see what Charles thinks.

 

You guys are great! I really appreciate that you've taken on my request. The flag routine is also really great!

 

Let me explain how your hard work is going to be used:

 

1.) I do some CAD work for an established golf course architect (on an as needed basis).

 

2.) He has been doing hand drawn designs for over 20 years. His computer skills are limited to no more than reading his emails. It would be unwise to try to totally convert him to autocad. He is an excellent designer and is very productive using paper and pencil.

 

3.) When needed, I convert his paper drawings into autocad by importing the project topo and inserting a scanned image of his drawings for each hole and then tracing his proposed contour lines and design features. This is a very time consuming process for me.

 

4.) I believe that using a Walcom drawing tablet, with some specifically designed routines, he will be able to "sketch" much of his design process just as if he was drawing on tracing paper.

 

5.) The first step in the design process, is to draw several proposed holes based on the topo and design expectations of the owners. For an 18 hole course, there may be as many as 20-30 possible hole locations.

 

6.) After selecting a proposed routing plan, I already have a golf design program which would allow him to sketch much of the remaining design process, just as he would do on paper.

 

7.) He would then turn the remainder of the work over to me to touch-up and finish the details for printing.

 

The major thing that is needed at this time, is to be able to "view" the proposed yardages as he is stretching the proposed centerlines, so that he would know what the approximate distance would be when he does a "left" click and continues, or "right" click to end the routine. Is this possible?

 

Sorry for being so long. Just thought an explanation was appropriate at this time.

 

Many Thanks... Jerry :D

Posted

Thanks Jerry for your compliments, its been great fun to work on this, and I have learnt a lot.

 

In later versions of ACAD, I'm pretty sure there was a "Dynamic Input Setting" introduced which would allow the user to see how long and at what angle the line was being drawn at, in real-time.

 

See here:

 

http://uk.youtube.com/watch?v=AUfvKT6gn_0&feature=related

 

Thanks

 

Lee

Posted

You could run a lisp to do the following:

 

Select pline near the vertex to stretch

Using grvecs function show the new vertex & adjacent segments with the yardage

If the user picks a point then edit the existing pline & update the existing text.

 

The text would need to be linked to the pline VIA xdata

 

This assumes the grvecs & xdata are available in R14.

 

I don't have time to create the list today, maybe on Saturday if no one has done it. This would be a good challenge for you Lee.

 

This may be a good reference.

http://cadtutor.net/forum/showpost.php?p=29263&postcount=4

Posted

Although, would the dynamic input setting work if the base drawing unit was set to yards in the LISP routine?

Posted

Here is a start, don't have any time.

You can build on this:

(defun c:vtEdit( / ent pt pl plElsist dx plvert plast tmpPt pp dist MinDist v1 vidx idx)

 (setq ent (entsel "\nSelect vertex to streatch."))
 (setq pt (cadr ent)
       pl (car ent))
 ;; get vertex list from pline--------------------------
 (setq plElist (entget pl))
 (while (setq dx (car plElist))
   (setq PlElist (cdr PlElist))
   (if (= (car dx) 10)
     (setq plvert (cons (cdr dx) plvert))
   )
 )
 (setq plvert (reverse plvert))

 ;;  find nearest vertex  ---------------------------------
 ;;  will noy work on a bulge
 (setq idx 0)
 (foreach v plvert
   (cond
     ((null plast)  (setq plast v))

     ;;  get perp point on the segment & test to find the closest
     ;;  point to any segment
     ((and
        (setq tmpPt (polar pt (+ (/ pi 2) (angle Plast v)) 10.0))
        (setq pp (inters Plast v pt tmpPt nil))
        (setq dist (distance v pp))
        (or MinDist (setq MinDist dist))
        (<= dist MinDist)
      )
          (setq Plast v
                MinDist dist
                vidx idx
          )

      )
     )
   (setq idx (1+ idx))
   ) ; foreach

 (setq v0 (nth (1- vidx) plvert)
       v1 (nth vidx plvert)
       v2 (nth (1+ vidx) plvert)
       )

 ;;  user streatch
 (while
   (progn
     (setq grr (grread t 7 0)
           inp (car grr)
     )
     (cond
       ((= inp 2)  ; Keyboard input
        (if (< 31 (setq key (cadr grr)) 255) ; a key was pressed
          (if (/= key 13)  ; exit on [ENTER]
            t ; stay in loop
            (setq upt nil) ; exit loop with nil point
          )
        )
       )
       ((= inp 3)  ; Selected 3d point
        (setq upt (cadr grr))
        nil ; Exit loop
       )
       ;|

       ((or (= inp 25) (= inp 11)) ; Right Click
        (print "Right Click = ")
        (princ pt) ; last known point !!
        
        ;;   Insert your block here using pt
        
        nil        ; exit
       )
       |;
       
       ((= inp 5)  ; pointing device
        (setq pt (cadr grr))
        (or LastPt (setq LastPt pt))
        (if (equal pt LastPt 0.0001)
          t ; do nothing
          
          ;;  point moved so redisplay
          (progn
            (grvecs (list 256 v0 pt pt v2))
            ;;  need to update text of Yards
            t ; stay in loop
          )
        )
       )

     )
   )
 )
 (if upt ; update pline
   (progn ; vidx points to vertex to be updated
     (princ)
   )
 )
 (princ)
)

Posted

Thats a good start CAB, although I doubt I have the knowledge to build on it! My knowledge of grvecs is very limited indeed...

 

I read the ACAD Help file on it and see that it uses a vector list and transformation Matrix - I have come across these on my Maths degree last term, but not sure how to apply them to this situation.

Posted

Updated to modify the pline.

Next we need a way to edit the text diplaying yards for each segment.

It would be nice if the text was aligned with the segment.

This would simplify our task.

Too tired to think. Good night.

(defun c:vtEdit( / ent pt pl plElsist dx plvert plast tmpPt pk pp dist MinDist v1 vidx idx)

 (setq ent (entsel "\nSelect vertex to streatch."))
 (setq pt (cadr ent)
       pl (car ent))
 ;; get vertex list from pline--------------------------
 (setq plElist (entget pl))
 (while (setq dx (car plElist))
   (setq PlElist (cdr PlElist))
   (if (= (car dx) 10)
     (setq plvert (cons (cdr dx) plvert))
   )
 )
 (setq plvert (reverse plvert))

 ;;  find nearest vertex  ---------------------------------
 ;;  will noy work on a bulge
 (setq idx 0)
 (foreach v plvert
   (cond
     ((null plast)  (setq plast v))

     ;;  get perp point on the segment & test to find the closest
     ;;  point to any segment
     ((and
        (setq tmpPt (polar pt (+ (/ pi 2) (angle Plast v)) 10.0))
        (setq pp (inters Plast v pt tmpPt nil))
        (setq dist (distance pt pp))
        (or MinDist (setq MinDist dist))
        (<= dist MinDist)
      )
          (setq Plast v
                MinDist dist
                vidx idx
                pk pp
          )

      )
     )
   (setq idx (1+ idx))
   ) ; foreach

 (setq v0 (nth (1- vidx) plvert)
       v1 (nth vidx plvert)
       v2 (nth (1+ vidx) plvert)
       )
  (if (< (distance v0 pk)(distance pk v1))
    (setq v2 v1
          v1 v0
          v0 (if (= vidx 1) nil (nth (- vidx 2) plvert)))
  )

 ;;  user streatch
 (while
   (progn
     (setq grr (grread t 7 0)
           inp (car grr)
     )
     (cond
       ((= inp 2)  ; Keyboard input
        (if (< 31 (setq key (cadr grr)) 255) ; a key was pressed
          (if (/= key 13)  ; exit on [ENTER]
            t ; stay in loop
            (setq upt nil) ; exit loop with nil point
          )
        )
       )
       ((= inp 3)  ; Selected 3d point
        (setq upt (cadr grr))
        nil ; Exit loop
       )
       ;|

       ((or (= inp 25) (= inp 11)) ; Right Click
        (print "Right Click = ")
        (princ pt) ; last known point !!
        
        ;;   Insert your block here using pt
        
        nil        ; exit
       )
       |;
       
       ((= inp 5)  ; pointing device
        (setq pt (cadr grr))
        (or LastPt (setq LastPt pt))
        (if (equal pt LastPt 0.0001)
          t ; do nothing
          
          ;;  point moved so redisplay
          (progn
            (redraw)
            (cond
              ((null v0) (grvecs (list 256 pt v2)))
              ((null v2) (grvecs (list 256 v0 pt)))
              ((grvecs (list 256 v0 pt pt v2)))
            )
            ;;  need to update text of Yards
            t ; stay in loop
          )
        )
       )

     )
   )
 )
 (redraw)
 (if upt ; update pline
   (progn ; vidx points to vertex to be updated
     (setq plElist (entget pl))
     (entmod (subst (cons 10 upt)(cons 10 v1) plElist))
     (princ)
   )
 )
 (princ)
)

Posted

Chiping away at it. :)

Still not there yet. Not using vl functions is killing me.:huh:

(defun c:vtEdit( / ent pt pl plElsist dx plvert plast tmpPt pk pp dist MinDist v1 vidx idx
               Len1 Len2 TxtEnt1 TxtEnt2)
 (or TxtSize (setq txtSize 30.0))
 (setq ent (entsel "\nSelect vertex to streatch."))
 (setq pt (cadr ent)
       pl (car ent))
 ;; get vertex list from pline--------------------------
 (setq plElist (entget pl))
 (while (setq dx (car plElist))
   (setq PlElist (cdr PlElist))
   (if (= (car dx) 10)
     (setq plvert (cons (cdr dx) plvert))
   )
 )
 (setq plvert (reverse plvert))

 ;;  find nearest vertex  ---------------------------------
 ;;  will noy work on a bulge
 (setq idx 0)
 (foreach v plvert
   (cond
     ((null plast)  (setq plast v))

     ;;  get perp point on the segment & test to find the closest
     ;;  point to any segment
     ((and
        (setq tmpPt (polar pt (+ (/ pi 2) (angle Plast v)) 10.0))
        (setq pp (inters Plast v pt tmpPt nil))
        (setq dist (distance pt pp))
        (or MinDist (setq MinDist dist))
        (<= dist MinDist)
      )
          (setq Plast v
                MinDist dist
                vidx idx
                pk pp
          )

      )
     )
   (setq idx (1+ idx))
   ) ; foreach

 (setq v0 (nth (1- vidx) plvert)
       v1 (nth vidx plvert)
       v2 (nth (1+ vidx) plvert)
       )
  (if (< (distance v0 pk)(distance pk v1))
    (setq v2 v1
          v1 v0
          v0 (if (= vidx 1) nil (nth (- vidx 2) plvert)))
  )

 ;;  user streatch
 (while
   (progn
     (setq grr (grread t 7 0)
           inp (car grr)
     )
     (cond
       ((= inp 2)  ; Keyboard input
        (if (< 31 (setq key (cadr grr)) 255) ; a key was pressed
            t ; stay in loop with letter or number key
          (if (= key 13)  ; exit on [ENTER]
            (progn
              (and TxtEnt1 (entdel (cdr(assoc -1 TxtEnt1))))
              (and TxtEnt2 (entdel (cdr(assoc -1 TxtEnt2))))
              (setq upt nil) ; exit loop with nil point
            )
            t ; stay in loop, not Enter key
          )
        )
       )
       ((= inp 3)  ; Selected 3d point
        (setq upt (cadr grr))
        nil ; Exit loop
       )
       ;|

       ((or (= inp 25) (= inp 11)) ; Right Click
        (print "Right Click = ")
        (princ pt) ; last known point !!
        
        ;;   Insert your block here using pt
        
        nil        ; exit
       )
       |;
       
       ((= inp 5)  ; pointing device
        (setq pt (cadr grr))
        (or LastPt (setq LastPt pt))
        (if (equal pt LastPt 0.0001)
          t ; do nothing
          
          ;;  point moved so redisplay
          (progn
            (redraw)
            (cond
              ((null v0) ; Starting Vertex
               (grvecs (list 256 pt v2))
               ;;(or txtent2 (setq txtent2 (getTextEnt v1 v2)))
               )
              ((null v2) ; Ending Vertex
               (grvecs (list 256 v0 pt))
               ;;(or txtent1 (setq txtent1 (getTextEnt p?)))
               )
              (t ; Middle Vertex
               (grvecs (list 256 v0 pt pt v2))
               ;;(or txtent1 (setq txtent1 (getTextEnt p?)))
               ;;(or txtent2 (setq txtent2 (getTextEnt p?)))
               )
            )
            ;;  need to update text of Yards
            (if (and v0
                     (not(equal Len1 (setq Len1 (/ (distance v0 pt) 3.)) 0.1))
                )
              (progn
                ;|
        ;; Get angle 90 deg to curve
        (setq curDer (vlax-curve-getfirstderiv cCurve
                       (vlax-curve-getparamatpoint cCurve nextPt)))
        (if (= (cadr curDer) 0.0)
          (setq curAng (/ pi 2))
          (setq curAng (- pi (atan (/ (car curDer) (cadr curDer)))))
        )
        (setq OffPt  (polar nextPt curAng (* 1.5 txtSize)))
              |;
              (if txtEnt1
                (setq TxtEnt1 (UpdateText TxtEnt1 (rtos Len1 2 1) pt))
                (setq TxtEnt1 (MakeText (rtos Len1 2 1) pt txtSize))
              )
               )
            )
            
            t ; stay in loop
          ) ; progn
        )
       )

     )
   )
 )
 (redraw)
 (if upt ; update pline
   (progn ; vidx points to vertex to be updated
     (setq plElist (entget pl))
     (entmod (subst (cons 10 upt)(cons 10 v1) plElist))
     (princ)
   )
 )
 (princ)
)

(defun UpdateText (tLst dis$ pt)
 (setq tLst (subst (cons 1 dis$)(assoc 1 tLst) tLst))
 (if (= (cdr(assoc 72 tLst))(cdr(assoc 73 tLst)) 0)
   (setq tLst (subst (cons 10 pt)(assoc 10 tLst) tLst))
   (setq tLst (subst (cons 11 pt)(assoc 11 tLst) tLst))
 )
 (entmod tLst)  
)

(defun MakeText (Txt pt h)
 (entget
 (entmakex
   (list '(0 . "TEXT")
         '(8 . "DESIGN-PROP-CTR-LINES-YARDS")
         (cons 10 pt)
         (cons 40 h)
         (cons 1 txt)
         '(50 . 0.0)
         '(7 . "STANDARD")
         '(71 . 0)
         '(72 . 0)
         '(73 . 0)
         '(62 . 256) ; color bylayer
         (cons 11 pt)
   ) 
 )
 )
) ;_  end defun)

Posted
Not using vl functions is killing me.:huh:

 

I hardly use vl functions anyway - I find them too complicated :huh:

  • 2 weeks later...
Posted

CAB,

 

Once again, I appreciate everyone's help on my request.

 

I've been silent for a few days because I was getting an "Unhandled Access Violation Exception" error, when using the "PropGolfCenterLines5.lsp" program. It was driving me up a tree! I searched the Internet, modified memory settings, reloaded R14, tested it in XP and Vista, but could not determine why I was getting this error message. Finally, using my most logical side of my brain, (I'm not sure which side it's on...) I finally found out what was causing it.

 

In ALL occurences (XP or VISTA), the OSNAP was set to "ON"!!! Turn the OSNAP "Off", no errors. Turn it back "On" and bingo!

 

 

If you would like to test your version of AutoCAD using the attached "PropGolfCenterLines5.lsp" program and the other attached DWG file, I would be interested in your results and comments.

 

Just maybe, the OSNAP "On" setting, is what has been causing some of those other "Unhandled Access Violation Exception" error messages for others...

 

Hope this helps someone...

Jerry

TopoEndPts1.dwg

PropGolfCenterLines5.lsp

Posted

Just tested it on my machine (ACAD 04.)

 

Code works fine - but I haven't got a shape file that exists in the attached drawing.

Posted

Lee,

 

I copied the latest .shp and .shx line and gdt files from several newer releases into the R14 support directory, but still had the same errors as I did before.

 

I don't know what else to do...

Posted

I just tried it on 2000 & the ags.shx was missing but the routine worked except that the text & flag block were too large by a factor of at lease 2.

 

There are no commands except the pline command that the osnap might give problems.

At what point in the routine does it fail?

Posted

Looking through the routine there are still some commands like pedit & chprop & layer. One of these could cause a problem if the prompt responses are in the wrong order but osnap should have no influence on that.

 

I will try and eliminate the other commands tomorrow.

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