Jump to content

Recommended Posts

Posted

Hopefully a lisp routine....

I work in the electrical department of an engineering Co. and I need what is called a home run arrowhead that will place itself at the end of an arc or curved line. The arrowhead needs to be parallel to the curve or along the curve.

1. The ideal routine would be to place the arrowhead first and then have the arc come out of the back-end of the arrowhead so as to give two more points to place the arc.

I'm just asking for the world and see what I get.

2. Much shorter version would be to place the arc on my own and then invoke a lisp routine to place the arrowhead on the end of the arc. The .lisp would call for a block (the arrowhead) to be placed.

3. Place block by-layer, color by-layer, line type by-layer.

4. Name of block (EARR).

5. Layer name (E-LITE-CIRC)

6. File attached.

Thank you very much in advance for your help.

Drawing1.dwg

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • ReMark

    10

  • bbryson_2000

    10

  • tombu

    8

  • iconeo

    4

Top Posters In This Topic

Posted Images

Posted

This could be modified to work. I use it to add special symbols to the ends of lines and plines.

 

I'm not sure where this code came from as I inherited it with the job and I just modded it...

Note that it requires that the layer already be present. Easily fixable.

 

(defun DXF (code lst)
  (cdr (assoc code lst))
)

(defun rtd (x) (* x (/ 180.0 pi)))

(defun dtr (x) (* pi (/ x 180.0)))

(defun addblocktoend (strBlockPath strBlockName setScale setLayer /
                   objEnt pt1 pt2 ent2 layName ang lts objType)

  (while (setq objEnt (entsel "\n Select a point on a line/pline/arc... "))
     (progn
        (setq objType (cdr (assoc 0 (entget (car objEnt)))))
        (princ objType)
        (setq pt1 (osnap (cadr objEnt) "_nea"))
        (setq pt2 (osnap (cadr objEnt) "_endp"))
        (setq ent2 (entget (setq entList (car objEnt))))

;         (if (= strUseDIMscale "Y")
;            (setq lts (getvar "dimscale"))
;            (setq lts 1.0)
;         )
;         (setq layName (DXF 8 ent2))

 (setq restoreclayer (getvar "clayer"))
 (if (= setLayer "OBJECTLAYER")
     (setvar "clayer" (DXF 8 ent2))
     (setvar "clayer" setLayer)
 )
;         (setvar "clayer" setLayer)
        (setq ang (angle pt1 pt2))
        (command "-insert" (strcat strBlockPath strBlockName) pt2 setScale "" (rtd ang))
 (setvar "clayer" restoreclayer)
     )
  )
  (princ)
)

(defun c:addblocktoend_linebreak ()
(setq slocation "V:\\AutoCAD\\Blocks\\Standard\\misc\\")
(setq sblock "BREAK_PIPE_END")
(setq sscale (/ (getvar "dimscale") 12))
(setq slayer "S-ANNO-BKLN")

(addblocktoend slocation sblock sscale slayer)
)

(defun c:addblocktoend_moment ()
(setq slocation "V:\\AutoCAD\\Blocks\\Standard\\leaders\\")
(setq sblock "ldr_moment")
(setq sscale (/ (getvar "dimscale") 12))
(setq slayer "OBJECTLAYER")

(addblocktoend slocation sblock sscale slayer)
)

(defun c:addblocktoend_singlearrow ()
(setq slocation "V:\\AutoCAD\\Blocks\\Standard\\leaders\\")
(setq sblock "ldr_single_arrow")
(setq sscale (/ (getvar "dimscale") 12))
(setq slayer "S-ANNO-DIMS")

(addblocktoend slocation sblock sscale slayer)
)

Posted (edited)

This one matches the one in your drawing exactly and uses Current Anno Scale for the arrowhead size and sets the linetype to continuous. Change the scale and the next one drawn will match that scale.

;| Arc Leader for labeling
  BY: Tom Beauford
  BeaufordT@LeonCountyFL.gov
  Leon County Public Works Engineering Section
  Macro: ^P(or C:ld (load "Leader.lsp"));ld
  Command line: (load "Leader.lsp") ld
================================================|;
(defun C:ld (/ *ERROR* st_txt osm othm cur_lt pt1 pt2)

(defun *ERROR* (s)                  ; If an error (such as CTRL-C) occurs
 (if (/= s "Function cancelled")     ; while this command is active...
   (princ (strcat "\nError: " s))
 )
 (redraw)
 (setq s nil)
 (setvar "osmode" osm)
 (setvar "orthomode" othm)
 (setvar "celtype" cur_lt)
 (setvar "plinewid" 0.0)
 (setvar "cmdecho" 0)
 (grtext -1 "") ;CLEAR STATUS LINE
 (command "_REGEN")
 (setq *error* olderr)               ; Restore old *error* handler
 (princ)
)

(setq st_txt (strcat "Arrow size = Text Size = " (rtos(/ 0.1 (getvar "cannoscalevalue"))2 2)))
; (setq st_txt (strcat "Arrow size = Text Size = " (rtos(getvar "textsize")2 2)))
(grtext -1 st_txt)
(setq osm (getvar "osmode"))
(setq othm (getvar "orthomode"))
(setq cur_lt (getvar "celtype"))
(setvar "osmode" 0)
(setvar "orthomode" 0)
(setvar "celtype" "CONTINUOUS")
(setq
 pt1 (getpoint "Start at object to be labeled: ")
 pt2 (getpoint pt1 "Tangent Direction Point: "))
(setq
 pt1 (list(car pt1)(cadr pt1))
 pt2 (list(car pt2)(cadr pt2))
 pt2
  (list
   (- (car pt1)(* (/ (/ 0.1 (getvar "cannoscalevalue")) (distance pt1 pt2))
      (-(car pt1)(car pt2)))
   )
   (- (cadr pt1)(* (/ (/ 0.1 (getvar "cannoscalevalue")) (distance pt1 pt2))
      (-(cadr pt1)(cadr pt2)))
   )
  )
)
(setvar "cmdecho" 0)
(command "_pline" pt1 "w" 0 (/ (/ 0.1 (getvar "cannoscalevalue")) 3)
; (command "_pline" pt1 "w" 0 (/ (getvar "textsize") 3)
;      pt2 "a" "w" (/ (getvar "textsize")30)(/ (getvar "textsize")30))
     pt2 "a" "w" 0 0)
(setvar "cmdecho" 1)
(while (= 1 (logand 1 (getvar "cmdactive")))
  (command PAUSE)
)
(setvar "plinewid" 0.0)
(setvar "osmode" osm)
(setvar "orthomode" othm)
(setvar "celtype" cur_lt)
(setvar "cmdecho" 0)
(grtext -1 "") ;CLEAR STATUS LINE
(command "_REGEN")
(princ)
)

Edited by tombu
add comment
  • 3 weeks later...
Posted

Thanks for the code but I don't see how to start this routine.

Usually there is a defun name at the beginning of the .lsp.

Posted

You are referring to the first lisp routine posted by iconeo?

Posted (edited)
Thanks for the code but I don't see how to start this routine.

Usually there is a defun name at the beginning of the .lsp.

 

I put both the macro you would add to the CUI and what to enter at the Command Line: in the comments at the beginning of my routine which matched the one in your drawing exactly. Enter ld to start the routine after it's loaded by entering (load "Leader.lsp") first.

 

iconeo's code defuns a few functions look for one's that start with defun c: addblocktoend_singlearrow appears to add an arrowhead to the end of an existing segment.

Edited by tombu
more detail to explnation
Posted

bb: From what I can tell iconeo has included three different defuns in his routine for, as he says, adding special symbols. It pays to read through the entire code before commenting.

Posted

I don't need two arrows, just one and I don't know how to edit code.

Thanks anyway

Posted

iconeo's code has a single arrow. And all you have to edit is the name of the block you're using for the single arrowhead. No one is asking you to become a lisp guru but you should learn some basic skills as they might come in handy down the road. Stop being so hard headed.

Posted
I don't need two arrows, just one and I don't know how to edit code.

Thanks anyway

 

I opened your drawing and the code I posted drew exactly the same arrow as in the drawing the way you wanted the "ideal routine" to do. Did you try it?

Posted

Because I read through the entire code before commenting I knew there was no c: defun and didn't know what the other defuns were for. And still don't. Typing in "RTD" or "DTR" I came up with nothing. YES - After loading the .lsp routine. I'm lost when it comes to code. That's why I rely on the knowledge and patience of others.

Posted

You are mistaken. There are three defun c: in iconeo's code. I'm legally blind in my right eye and yet I can clearly see them.

 

DEFUNS3.PNG

Posted

I think you owe Tom an answer re: his code.

Posted
Because I read through the entire code before commenting I knew there was no c: defun and didn't know what the other defuns were for. And still don't. Typing in "RTD" or "DTR" I came up with nothing. YES - After loading the .lsp routine. I'm lost when it comes to code. That's why I rely on the knowledge and patience of others.

 

That's iconeo's code. I opened your drawing and the code I posted drew exactly the same arrow as in the drawing the way you wanted the "ideal routine" to do.

 

I put both the macro you would add to the CUI and what to enter at the Command Line: in the comments at the beginning of my routine which matched the one in your drawing exactly. Enter ld to start the routine after it's loaded by entering (load "Leader.lsp") first.

 

Just try it.

Posted

The OP seems to be stuck on the first code posted and appears not to have tried your code Tom.

Posted

Your really critical with people who are asking for help.

Hard headed is someone that will not even try.

I'm sure you were born with this knowledge.

The rest of us have to put in the effort to try or ask for help.

Posted

Are you going to continue complaining or are you going to make an effort to try Tom's code?

Posted
Your really critical with people who are asking for help.

Hard headed is someone that will not even try.

I'm sure you were born with this knowledge.

The rest of us have to put in the effort to try or ask for help.

 

Sorry, we're just trying to help. Having trouble answering you when you never mention which code you're referring to and we both tried to help you. We told you how to find the functions and I even included the name of the function in iconeo's code that does the "shorter version" you described.

 

Still wonder why you haven't looked at the code I posted as it does as you asked for an "ideal routine".

Posted

It helps to learn even a little code. This situation reminds of when I see someone stuck on the side of the road because they never learned how to change a tire. Just the basics I'm sayin'. After all it's a tool you use 40 hours a week...

 

Sent from my SM-G920T using Tapatalk

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