How to Use a LISP? Line by Bearing and DIstance

How to Use a LISP? Line by Bearing and DIstance

JohnC_ISM
Collaborator Collaborator
4,319 Views
14 Replies
Message 1 of 15

How to Use a LISP? Line by Bearing and DIstance

JohnC_ISM
Collaborator
Collaborator

i downloaded a Line by Bearing LISP and installed it but have no idea how to actually use it. 

 

its a lisp that uses LINE, then 'BD. 

 

maybe someone has another LISP for this same command. 

attached is the lisp i downloaded. 

 

 

then im also looking for one to add static labels of bearing and distance as well

0 Likes
4,320 Views
14 Replies
Replies (14)
Message 2 of 15

Kent1Cooper
Consultant
Consultant

@JohnC_ISM wrote:

i downloaded a Line by Bearing LISP and installed it but have no idea how to actually use it. 

 

its a lisp that uses LINE, then 'BD. 

.... 

 

then im also looking for one to add static labels of bearing and distance as well


To use it, in a drawing, type AP [the alias for APPLOAD], navigate to where you have the file, and Load it.  Then type its command name: DB.  [It doesn't "use LINE" if by that you mean that a Line command is included in it, but rather it asks the User to select a Line or Lines.]

 

It looks like it labels Lines with bearing and distance.  Is that not the case?  [I haven't tested it.]  There are certainly other routines that will do that, if DB doesn't do what you need.

Kent Cooper, AIA
0 Likes
Message 3 of 15

john.uhden
Mentor
Mentor

Sorry, but I can't stomach looking at code with no indentations.

 

BUT, I do have a killer of a labeling program... lines, arcs, polylines (even if nested in an xref), sequentially numbered tags with leaders, and tables complete with from and to coordinates.  It's almost as good as C3D (I wrote it before Land Desktop came around and adapted it to handle north rotation).  I used to sell it, but those days are long gone.  Nevertheless, I would have to be convinced to give it away.  I would have to remove the security and repackage it as a VLX to include the dialog file.  Why not get into C3D?

John F. Uhden

0 Likes
Message 4 of 15

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:
....  There are certainly other routines that will do that, if DB doesn't do what you need.

For example, here is the one I use, which labels Lines or Arcs, and will do it as you draw them within the commands whose names have a D in the middle [for Draw] or will add the labeling to already-drawn ones with the commands with an M in the middle [for Mark].

Kent Cooper, AIA
0 Likes
Message 5 of 15

JohnC_ISM
Collaborator
Collaborator

i actually do have it. but im being forced to use cad 2004. its terrible but its one of those companies thats been using the same thing forever so all the files are on 2004. 

 

the new ones i could start using and making on C3D'10 at least. or even Cad'15-16 but the back and forth between new and old gets annoying. id have to start from scratch. 

0 Likes
Message 6 of 15

JohnC_ISM
Collaborator
Collaborator

i might have downloaded the wrong thing. i just need something that does LINE, then 'BD

 

 

altho thank you for pointing out the DB thing. i couldnt find anything online as to how to use it as a command, only how to load it. 

0 Likes
Message 7 of 15

Kent1Cooper
Consultant
Consultant

@JohnC_ISM wrote:

i might have downloaded the wrong thing. i just need something that does LINE, then 'BD .... 


'BD is not a native AutoCAD command.  Do you have a custom command definition, or is that maybe something in a Civil-Engineering or Surveying overlay program?

Kent Cooper, AIA
0 Likes
Message 8 of 15

Ranjit_Singh
Advisor
Advisor

@Kent1Cooper 'BD is a transparent command for Bearing and Distance on Civil 3D.

@JohnC_ISM Are you saying you need to simply call line and then 'bd? If so, try below function.

(defun c:lbd() (command "._line" pause "'bd"))
0 Likes
Message 9 of 15

JohnC_ISM
Collaborator
Collaborator

but what do i do with that? copy and paste it into the lisp creator? 

0 Likes
Message 10 of 15

Ranjit_Singh
Advisor
Advisor

You take that line of code and put it in a text file. Save the file with .lsp extension. Load that file using command appload. Now you simply type the command lbd at command line to call the command.

You should google "Load Autolisp files" since there are other methods of loading. Or search on these forums.

0 Likes
Message 11 of 15

john.uhden
Mentor
Mentor

Ranjit's answer is good, as usual.  If you intend to use his routine often, then I would copy and paste his line of code into your acaddoc.lsp file.

 

You can find out where it is by entering (FINDFILE "ACADDOC.LSP"), with parentheses, at the command prompt.  If that returns nil then create the acaddoc.lsp file and put it in the first path as listed under the Options command -> Support File Search Path.

 

acaddoc.lsp is loaded automatically with every open or new drawing command, so the command will always be available.

John F. Uhden

Message 12 of 15

telze33
Contributor
Contributor

When I create the LISP routine as described above, and execute the command, the first line command doesn't go through and it isn't drawn.  Any idea why that is?  After that, everything works as normal

0 Likes
Message 13 of 15

john.uhden
Mentor
Mentor

Doesn't work right for me either.

That must be why I use my own, which works exactly like DCA/Softdesk/Land Desktop.

John F. Uhden

0 Likes
Message 14 of 15

Kent1Cooper
Consultant
Consultant

@telze33 wrote:

When I create the LISP routine as described above, and execute the command, the first line command doesn't go through and it isn't drawn.  Any idea why that is?  After that, everything works as normal


If you're talking about the DISTBEAR.lsp routine at Message 1, I find not only that it doesn't work as described there [see Message 2], but in actually trying it out, it requires that the current Text Style has a fixed height.

Kent Cooper, AIA
0 Likes
Message 15 of 15

CADaSchtroumpf
Advisor
Advisor

I have this, if can be interrest you?

It work's with LWPOLYLINE (with ARC also) only but you can use pedit for your LINE

 

 

(vl-load-com)
(defun c:label_bearing ( / l_var js htx AcDoc Space nw_style n obj ename pr dist_start dist_end pt_start pt_end seg_len alpha val_txt dim_txt nw_obj)
  (setq l_var (mapcar 'getvar '("AUNITS" "AUPREC" "LUPREC" "LUNITS")))
  (mapcar 'setvar '("AUNITS" "AUPREC" "LUPREC" "LUNITS") '(4 3 2 2))
  (princ "\nSelect polylines.")
  (while (null (setq js (ssget '((0 . "LWPOLYLINE")))))
    (princ "\nSelection is empty or not are LWPOLYLINE!")
  )
  (initget 6)
  (setq htx (getdist (getvar "VIEWCTR") (strcat "\nSpecify text height <" (rtos (getvar "TEXTSIZE")) ">: ")))
  (if htx (setvar "TEXTSIZE" htx))
  (setq
    AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    Space
    (if (= 1 (getvar "CVPORT"))
      (vla-get-PaperSpace AcDoc)
      (vla-get-ModelSpace AcDoc)
    )
  )
  (vla-startundomark AcDoc)
  (cond
    ((null (tblsearch "LAYER" "DIMENSIONS"))
      (vlax-put (vla-add (vla-get-layers AcDoc) "DIMENSIONS") 'color 7)
    )
  )
  (cond
    ((null (tblsearch "STYLE" "ELEV_ARIAL_1"))
      (setq nw_style (vla-add (vla-get-textstyles AcDoc) "ELEV_ARIAL_1"))
      (mapcar
        '(lambda (pr val)
          (vlax-put nw_style pr val)
        )
        (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
        (list (strcat (getenv "windir") "\\fonts\\arial.ttf") 0.0 0.0 1.0 0.0)
      )
    )
  )
  (repeat (setq n (sslength js))
    (setq
      obj (ssname js (setq n (1- n)))
      ename (vlax-ename->vla-object obj)
      pr -1
    )
    (repeat (fix (vlax-curve-getEndParam ename))
      (setq
        dist_start (vlax-curve-GetDistAtParam ename (setq pr (1+ pr)))
        dist_end (vlax-curve-GetDistAtParam ename (1+ pr))
        pt_start (vlax-curve-GetPointAtParam ename pr)
        pt_end (vlax-curve-GetPointAtParam ename (1+ pr))
        seg_len (- dist_end dist_start)
        alpha (angle (trans pt_start 0 1) (trans pt_end 0 1))
        val_txt (vl-string-subst "%%d" "d"(strcat (angtos alpha) " " (rtos seg_len)))
        dim_txt (textbox (list (cons 1 val_txt)))
      )
      (if (and (> alpha (* pi 0.5)) (< alpha (* pi 1.5))) (setq alpha (+ alpha pi)))
      (if (> (distance (car dim_txt) (cadr dim_txt)) seg_len)
        (setq val_txt (vl-string-subst "E \\P" "E " val_txt))
      )
      (setq nw_obj
        (vla-addMtext Space
          (vlax-3d-point (setq pt (polar (vlax-curve-GetPointAtParam ename (+ 0.5 pr)) (+ alpha (* pi 0.5)) (getvar "TEXTSIZE"))))
          0.0
          val_txt
        )
      )
      (mapcar
        '(lambda (pr val)
          (vlax-put nw_obj pr val)
        )
        (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation)
        (list 8 (getvar "TEXTSIZE") 5 pt "ELEV_ARIAL_1" "DIMENSIONS" alpha)
      )
    )
  )
  (vla-endundomark AcDoc)
  (mapcar 'setvar '("AUNITS" "AUPREC" "LUPREC" "LUNITS") l_var)
  (prin1)
)

 

0 Likes