Author Topic: Detail routine  (Read 4213 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Swamp Rat
  • Posts: 502
Detail routine
« on: July 17, 2012, 08:10:24 AM »
Does anyone have or know where I might find a routine that will create an arc with arrowheads on each end and call for a letter to be inserted between the arrows?
I've had one for years, but after a PC melt down , mine has disappeared and our IT people have messed up my backup files. ARGH!
I used this for creating "detail" views using current dimscale, section lines, & text height.

hmspe

  • Bull Frog
  • Posts: 362
Re: Detail routine
« Reply #1 on: July 17, 2012, 08:48:06 AM »
Can you provide a picture of whet the finished product should look like?  A portion of a finished drawing that shows its use in context would be ideal.
"Science is the belief in the ignorance of experts." - Richard Feynman

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Detail routine
« Reply #2 on: July 17, 2012, 09:02:18 AM »
Quickly written:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:aarc ( / *error* an1 an2 an3 ang arl arw cen ent enx rad )
  2.  
  3.     (setq arl 1.0 ;; Arrow Length
  4.           arw 0.5 ;; Arrow Width
  5.     )
  6.  
  7.     (defun *error* ( msg )
  8.         (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
  9.             (princ (strcat "\nError: " msg))
  10.         )
  11.         (princ)
  12.     )
  13.  
  14.     (setq ent (entlast))
  15.     (command "_.arc")
  16.     (while (= 1 (logand 1 (getvar 'cmdactive)))
  17.         (command pause)
  18.     )
  19.     (if (not (eq ent (setq ent (entlast))))
  20.         (progn
  21.             (setq enx (entget ent)
  22.                   cen (cdr (assoc 10 enx))
  23.                   rad (cdr (assoc 40 enx))
  24.                   an1 (cdr (assoc 50 enx))
  25.                   an2 (cdr (assoc 51 enx))
  26.                   an3 (/ arl rad)
  27.                   ang (rem (+ pi pi (- an2 an1)) (+ pi pi))
  28.             )
  29.             (if (< arl (* rad ang))
  30.                 (if (entmake
  31.                         (list
  32.                            '(0 . "LWPOLYLINE")
  33.                            '(100 . "AcDbEntity")
  34.                            '(100 . "AcDbPolyline")
  35.                            '(90 . 4)
  36.                            '(70 . 0)
  37.                             (cons 10 (polar cen an1 rad))
  38.                            '(40 . 0.0)
  39.                             (cons 41 arw)
  40.                             (cons 42 (tan (/ an3 4.0)))
  41.                             (cons 10 (polar cen (+ an1 an3) rad))
  42.                            '(40 . 0.0)
  43.                            '(41 . 0.0)
  44.                             (cons 42 (tan (/ (- ang an3 an3) 4.0)))
  45.                             (cons 10 (polar cen (- an2 an3) rad))
  46.                             (cons 40 arw)
  47.                            '(41 . 0.0)
  48.                             (cons 42 (tan (/ an3 4.0)))
  49.                             (cons 10 (polar cen an2 rad))
  50.                         )
  51.                     )
  52.                     (entdel ent)
  53.                 )
  54.                 (princ "\nArc too short to accommodate arrows.")
  55.             )
  56.         )
  57.     )
  58.     (princ)
  59. )
  60.  
  61. ;; Tangent  -  Lee Mac
  62. ;; Args: x - real
  63.  
  64. (defun tan ( x )
  65.     (if (not (equal 0.0 (cos x) 1e-10))
  66.         (/ (sin x) (cos x))
  67.     )
  68. )
« Last Edit: July 17, 2012, 04:44:28 PM by Lee Mac »

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Detail routine
« Reply #3 on: July 17, 2012, 09:17:22 AM »
Nice Lee :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Detail routine
« Reply #4 on: July 17, 2012, 09:21:13 AM »
Thanks Ron  :-)

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Detail routine
« Reply #5 on: July 17, 2012, 12:54:55 PM »
Here's the command line response I get. Using ACAD 2012 by the way.
And an attachment of what I'm looking for

Command: (LOAD "AARC")
TAN

Command: AARC
_.arc Specify start point of arc or
: C
Specify center point of arc:
Specify start point of arc:
Specify end point of arc or [Angle/chord Length]:
Command: ; error: bad DXF group: (41)

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Detail routine
« Reply #6 on: July 17, 2012, 12:58:41 PM »
Are you sure that you have downloaded the code correctly? Have you modified the code in any way?

The reason I ask is that I cannot reproduce the error and, from the error message you are receiving, the only explanation for that result would be if the variable 'arw' is not defined (i.e. is nil), however, this variable is clearly defined at the top of the code.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Detail routine
« Reply #7 on: July 17, 2012, 01:04:16 PM »
I'll try again. Thanks for your help by the way!

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Detail routine
« Reply #8 on: July 17, 2012, 01:07:44 PM »
You're welcome.  :-)

Looking at your drawing, you would need to change the arrow length to 0.09375 and the arrow width to 0.03125

By the way, why not use a dynamic attributed block for this purpose?


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Detail routine
« Reply #9 on: July 17, 2012, 01:10:59 PM »
Works here but was able to crash it with osnaps on. 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.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Detail routine
« Reply #10 on: July 17, 2012, 01:26:11 PM »
Works here but was able to crash it with osnaps on. 8-)

Zero radius arc?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Detail routine
« Reply #11 on: July 17, 2012, 01:55:23 PM »
Start & end points the same.
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.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Detail routine
« Reply #12 on: July 17, 2012, 02:10:57 PM »
Start & end points the same.

Surely not possible with an arc?  :?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Detail routine
« Reply #13 on: July 17, 2012, 02:24:43 PM »
Just saying that with careless snapping you can pick start & end as the same point & routine crashes.
No big deal, just start over. I know the routine is not fool prof.  :-)
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.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Detail routine
« Reply #14 on: July 17, 2012, 02:40:06 PM »
Just saying that with careless snapping you can pick start & end as the same point & routine crashes.
No big deal, just start over. I know the routine is not fool prof.  :-)

No big deal, but I just thought that it wasn't possible to pick coincident arc endpoints - the Arc command in 2010 doesn't allow it...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Detail routine
« Reply #15 on: July 17, 2012, 03:37:06 PM »
This is 2006, if VLIDE is active it shows the command pause as the source of the error.

Code: [Select]
Command: aarc
*Invalid*
; error: Function cancelled
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.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Detail routine
« Reply #16 on: July 17, 2012, 04:46:19 PM »
This is 2006, if VLIDE is active it shows the command pause as the source of the error.

Code: [Select]
Command: aarc
*Invalid*
; error: Function cancelled

Thanks. Since the error cannot be detected by the program whilst the Arc command takes focus, I think the best solution is to equip the program with a simple error handler.

Code updated.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Detail routine
« Reply #17 on: July 18, 2012, 08:48:44 AM »
Yup I did miss a line of code. Works very well now! Thank you.
I'll check into the "dynamic attributed block" idea. It's about time we tried using dynamic blocks anyway.

Thanks everyone, for all the help & suggestions!

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Detail routine
« Reply #18 on: July 19, 2012, 02:33:40 PM »
Just thought I would let everyone know, I was able to find and old copy of the "missing" routine.
And we're back in action again. Many thanks for all the help! Any who wish to use this are free to do so.

Code: [Select]
(defun C:DETL
         (/ ANG02    ANG021   ANG022    CLAY    CORM    COSM
            DETN      DSCL      PNT01       PNT02  PNT021  PNT022
           PNT023    PNT024  RAD01       RAD02  RAD03    LTSC
         )
                 ; DEFINE VARIABLES
                 ; ANG02 = ANGLE, PNT01 TO PNT02
                 ; CLAY = CURRENT LAYER
                 ; CORM = CURRENT ORTHO MODE
                 ; COSM = CURRENT OSNAP MODE
                 ; DETN = DETAIL NAME
                 ; DSCL = DIMSCALE
                 ; PNT01 = CENTER OF VIEW CIRCLE
                 ; PNT02 = LOCATION OF VIEW NAME
                 ; RAD01 = DISTANCE, PNT01 TO PNT02
                 ; RAD02 = DIMSCALE TIMES DETAIL ARROWHEAD SIZE
                 ; RAD03 = DIMSCALE TIMES TEXT HIGHT
                 ; LTSC = LTSCALE

  (setq   CLAY (getvar "CLAYER")
            CORM (getvar "ORTHOMODE")
            COSM (getvar "OSMODE")
            DSCL (getvar "DIMSCALE")
            LTSC (getvar "LTSCALE")
  )
  (setvar "CMDECHO" 0)
  (command "._-LAYER" "_NEW" "SECTION" "_COLOR" 230 "SECTION" "_LTYPE" "PHANTOM" "SECTION" "")
  (setvar "ORTHOMODE" 0)
  (setvar "OSMODE" 0)

  (setq    PNT01 (getpoint "\nPick center of View Circle: ")
             PNT02 (getpoint PNT01 "\nPick location of View Name: ")
             DETN  (getstring 2 "\nDetail Name? ")
             ANG02 (angle PNT01 PNT02)
             RAD01 (distance PNT01 PNT02)
             RAD02 (* DSCL 0.140625)
             RAD03 (* DSCL 0.09375)

  )
  (command "._LAYER" "_SET" "0" "" "._CIRCLE" PNT01 PNT02 "._CIRCLE" PNT02 RAD02)

       ;;   Set layer to 0 and draw the detail circle and a circle on the
       ;; circumference of the detail circle having a radius equal to 1.5
       ;; times the standard character hite (i.e., 9/64").  Record points,
       ;; angles, & distances involved.

  (setq    PNT021 (polar PNT02 (+ ANG02 (* pi 0.5)) RAD02)
             PNT021 (osnap PNT021 "APP")
             ANG021 (angle PNT01 PNT021)
             PNT022 (polar PNT02 (+ ANG02 (* pi 1.5)) RAD02)
             PNT022 (osnap PNT022 "APP")
             ANG022 (angle PNT01 PNT022)
  )
  ;; Get both points where the two circles intersect, & record the points
  ;; and the angles relative to the center of the large circle.
 
(command "._MOVE" "_LAST" "" PNT02 PNT021)

  (setq    PNT023 (polar PNT021 (+ ANG021 (* pi 0.5)) RAD02)
              PNT023 (osnap PNT023 "APP")
  )
  ;;   Shift the small circle counterclockwise one character height &
  ;; determine where one of the arrowheads will end

  (command "._MOVE" "_LAST" "" PNT021 PNT022)

  (setq    PNT024 (polar PNT022 (+ ANG022 (* pi 1.5)) RAD02)
             PNT024 (osnap PNT024 "APP")
  )

  ;; then shift it two character hights clockwise & get the endpoint
  ;; of the other arrowhead.




 (command "._ERASE" "_LAST" ""
                   "._CIRCLE" PNT02 PNT023
                   "._TRIM" "_LAST" "" PNT02 ""
                   "._ERASE" "_PREVIOUS" ""
;        "._PEDIT" "LAST" "YES" ""
                   "._CHANGE" "_LAST" "" "_PROPERTIES" "_LAYER" "SECTION" ""
                   "._LAYER" "SET" "SECTION" ""
                   "._PLINE" PNT021 "_WIDTH" 0.0 (* RAD02 0.38196601) PNT023 ""
                   "._MIRROR" "_LAST" "" PNT01 PNT02 "_NO"
                   ".-STYLE" "STANDARD" "ROMANS" "0" "1" "0" "N" "N" "N"
                   "._TEXT" "MC" PNT02 RAD03 0.0 (strcase DETN)
                   "._LAYER" "_SET" CLAY "")                  ;
  (princ)
)

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Detail routine
« Reply #19 on: July 19, 2012, 07:42:26 PM »
Just saying that with careless snapping you can pick start & end as the same point & routine crashes.
No big deal, just start over. I know the routine is not fool prof.  :-)
Even with routines that are fool proof, never underestimate the ingenuity of a fool.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Detail routine
« Reply #20 on: July 25, 2012, 08:37:02 AM »
Funny you should say that. I have a buddy who is no fool but unpredictable.
I used to have him test my FoxBASE routines and he did find the chinks in the armor.  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.