Author Topic: Lastangle...old code  (Read 4107 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Lastangle...old code
« Reply #15 on: June 04, 2008, 01:27:46 PM »
Nice one Ron.
I went back and modified my old FatLeader routine and added your sub.
Also added a correction for when the leader is too short for the head size.
My routine picks the head point first.

Code: [Select]
;;;   By Charles Alan Butler  : Last Modified 06/04/2008
;;;   FatL.lsp    (Fat Leader)
;;;  This routine will create a tapered three point pline arc leader with arrow head
;;;  The arrow head length & width may be changed within the code
;;;  Code corrects for too short a leader by reducing the arrow head
;;;   Uses the current layer

;;;======  Main Lisp Routine  =======
(defun c:FatL (/ usercmd  useros   pthead     ptstart      ptmid
               ptend err ArLen Width GetSpace totallen
              )
  (vl-load-com)

  (defun GETSPACE ()
    (if (and (zerop (getvar "TILEMODE"))
             (equal (getvar "CVPORT") 1)
        )
      1.0
      (getvar "DIMSCALE")
    )
  )

 
  (princ "\n")
  (princ "\n            Fat Leader - Version 3.0")
  (princ "\n")

  ;; -------  Some Housekeeping   ------------------
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq useros (getvar "osmode"))
  (setvar "osmode" 0)

  ;;-------------------------------------
  ;;-----   Set Arrow Head Size   ------
  ;;-------------------------------------
  ;|
  ;; Length = 6"  @ DimScale 48
  ;; Width = 1.5" @ DimScale 48
  (setq ArLen (* 0.125 (getvar "DIMSCALE")) ; Head length
        Width (* 0.03125 (getvar "DIMSCALE")) ; Head Width
  )
|;

  ;|
  (setq ArLen (* (getvar "dimasz") (getvar "dimscale")) ; Head length
        Width (/ ArLen 3.0) ; Head Width
  ) |;
  (setq ArLen (* (GETSPACE) 0.1250)  ; Head length
        Width (* (GETSPACE) 0.06250) ; Head Width
  )


 ;;-------------------------------------
 ;;-----   Get Leader Location    ------
 ;;-------------------------------------
  (setq ptstart (getpoint "\nPick arrow start, middle then end point: "))
  (setq ptmid (getpoint ptstart "\nPick middle then end point: "))
  (setq err (vl-catch-all-apply
               'vl-cmdf (list ".arc" ptstart
                              ptmid
                              pause
                              )))
                              (setq ptend (getvar "lastpoint"))
 
  (if (not (vl-catch-all-error-p err))
    (progn
      (setq ent (entlast))
      (setq totalLen (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)))
      ;;  correct for too short a leader, max head is 4:1
      (if (< TotalLen (* 4 Arlen)) ; scale the arrowhead down
        (setq ArLen (* TotalLen 0.2)
              Width (* TotalLen 0.1))
      )

     
      (if (equal (vlax-curve-getparamatpoint ent ptstart)
                 (vlax-curve-getstartparam ent) 0.0001)
           (setq pthead (vlax-curve-getpointatparam ent (vlax-curve-getparamatdist ent ArLen)))
           (setq pthead (vlax-curve-getpointatparam ent
                          (vlax-curve-getparamatdist ent
                            (- (vlax-curve-getdistatparam ent
                                 (vlax-curve-getendparam ent)) ArLen))))
      )
      (entdel ent) ; remove the ARC object


      ;; ----------   Draw the pline    ---------------
      (command "_.pline" "non" ptstart "w" "0" Width ; arrow head
               "non" pthead "w" "0" Width "A" "S" "non" ptmid ptend "")
    )
  )
  ;;==========  Exit Sequence  ============
  (setvar "osmode" useros)
  (setvar "CMDECHO" usercmd)
  (princ)
) ;  end defun
(prompt "\nType  FatL  to run")
(princ)
;;;==========  End of Routine  ============

That's a schmancy looking leader :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Lastangle...old code
« Reply #16 on: June 04, 2008, 02:25:58 PM »
Thanks you Sir.
Always looking for a differently look.  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Lastangle...old code
« Reply #17 on: June 04, 2008, 04:53:45 PM »
CAB,

Hope you don't mind but I modified your routine a bit to entmake the leader on a certain layer and use:

(list ".pline" ptstart "a" "s" ptmid pause "")

instead of

(list ".arc" ptstart ptmid pause)

Using the pline made it easy to extract the bulge and fixes the arrowhead from being skewed when using tighter angles as shown below :).

*the only real issue I've noticed is the arc gets bigger when the two endpoints are close together and the midpoint distance from them is far away....but that does not seem like a common occurrence.

Ron
« Last Edit: June 04, 2008, 05:03:38 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Lastangle...old code
« Reply #18 on: June 05, 2008, 12:28:06 AM »
Good job Ron. I'll look at the code in the am.
ZZZzzzzzzz......
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Lastangle...old code
« Reply #19 on: June 05, 2008, 09:59:21 AM »
Ron and Alan

Pretty neat routine. Me likey.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64