Jump to content

AutoCAD Layer LEGEND LISP customization HELP.


PoetEngineer

Recommended Posts

Hi everyone, a lot of people who are interesting in the engineering or another technics work have this lisp (I Shared bottom of my topic) as you know. however, this lisp is can't give me results that I want or I imagine, at the last times. I had a decision to customize this lisp for me and people who are want to reach goals like mine. I want to customize this lisp to draw hatch area values, line or polyline length values and count of block in drawing that I work in it. where should I start to customize the lisp to get my goals.

AutoCAD-Tutorial.thumb.jpg.b2e8aff76902d36368485f8f7941c890.jpgTHIS IS WHAT I WANT TO DO

 

 

Screenshot_1.thumb.png.3b29eeca57b2d2c4d85afa269c921791.png THIS IS WHAT I CAN DO NOW 

 

(defun C:LEGEND ( / *error* acdoc acobj an co e hs ht i la lst lt p p1 p2 p3 space ss st ro dr)
  (vl-load-com)
  (setq acObj (vlax-get-acad-object)
        acDoc (vla-get-activedocument acObj)
        space (vlax-get acDoc (if (= 1 (getvar 'cvport)) 'PaperSpace 'ModelSpace))
  )
  (vla-startundomark acDoc)
  
  ;;;;;; Error function ;;;;;;;;;
  (defun *error* (msg)
    (and
      msg
      (not (wcmatch (strcase msg) "*CANCEL*,*QUIT*,*BREAK*"))
      (princ (strcat "\nError: " msg))
      )
    (if (and a (not (vlax-erased-p a))) (vla-delete a))
    (vla-endundomark acDoc)
    (princ)
    )
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setq st (entget (tblobjname "style" (getvar 'textstyle)) '("AcadAnnotative"))
        an (member '(1070 . 1) (cdr (member '(1070 . 1) (cadr (assoc -3 st)))))
        hs (cdr (assoc 40 st))
        ro (angle '(0 0 0) (trans (getvar "UCSXDIR") 0 (trans '(0 0 1) 1 0 T)))
        dr (trans '(0 0 1) 1 0 T)
        )
  (if
    an
    (setq ht (/ (if (> hs 0) hs 3.0) (cond ((getvar 'cannoscalevalue)) (1.0))))
    (setq ht (* (if (> hs 0) hs 3.0) (getvar 'ltscale)))
    )
  (if
    (setq ss (ssget))
    (progn
      (repeat (setq i (sslength ss))
        (setq
          e  (entget (ssname ss (setq i (1- i))))
          la (cdr (assoc 8  e))
          lt (cdr (assoc 6  e))
          co (cdr (assoc 62 e))
        )
        (if
          (not (member (list la lt co) lst))
          (setq lst (cons (list la lt co) lst))
        )
      )
      (setq lst (vl-sort lst '(lambda (a b) (< (car a) (car b)))))
      (if
        (setq p (getpoint "\nSpecify insert point: "))
        (foreach x lst
          (setq p1 (trans p 1 0)
                p2 (trans (polar p 0.0 (* 10 ht)) 1 0)
                p3 (trans (polar p 0.0 (* 11 ht)) 1 0)
                )
          (entmake
            (list
              '(0 . "LINE")
              (cons 8 (car x))
              (cons 10 p1)
              (cons 11 p2)
              (cons 6  (cond ((cadr  x)) ("ByLayer")))
              (cons 62 (cond ((caddr x)) (256)))
              )
            )
          (vla-put-textalignmentpoint
            (vlax-ename->vla-object
              (entmakex
                (list
                  '(0 . "TEXT")
                  (cons 8 (car x))
                  (cons 6 (cond ((cadr x)) ("ByLayer")))
                  (cons 62 (cond ((caddr x)) (256)))
                  '(100 . "AcDbText")
                  (list 10 0 0 0)
                  (cons 40 ht)
                  (cons 1 (car x))
                  (cons 50 ro)
                  (cons 7 (getvar 'textstyle))
                  (cons 72 0)
                  (list 10 0 0 0)
                  (cons 210 dr)
                  (cons 73 2)
                )
              )
            )
            (vlax-3d-point p3)
          )
          (setq p (polar p (/ pi -2.0) (* 2 ht)))
          )
        )
      )
    )
  (*error* nil)
  (princ)
  )
 

 

 

 

LEGEND-AUTOCADDA SEÇİLEN ÇİZİM İÇERİSİNDEKİ LAYERLARI LEJANT HALİNE GETİREN LİSP.LSP

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Completely the wrong answer but might amuse someone somewhere.....Legends

 

 

Oh, and made up over time so the code is a bit bloated, I haven't stripped anything out the files, so some stuff in there is useless as well for this answer but load up the files and the command blklegend gives you 3 options. Inserts a legend block.

 

BLKLEGENDS.lspBLKWRITER.lsp

 

 

 

 

 

(this had work stuff behind it but I needed to test wat I was doing)

Link to comment
Share on other sites

Split this into 3 "hatch area values, line or polyline length values and count of block in drawing"

 

hatch area values,

line or polyline length values

count of blocks in drawing -  this can have a simple or complex answer if attributes get involved.

 

Each of these has been done numerous times. The next question is so get the answers then what a Table to Excel to a file ?

 

So google 3 times. Make them work 1 at a time rather than all 3 in one go.

Link to comment
Share on other sites

I found a lisp for hatch area to table but there is a problem that is about description of layer. if you look at the file those I share with you then you'll see dwg file has like "LOT 50" etc. layer description. in addition when I using this lisp I can't see my hatch pattern. So what's wrong with my files. 

my second question is how can I create a layer with "LOT 50" description?

 

(setq b(command "-LAYER" "M" "____00-AF-MAHAL ÖLÇÜLENDİRME " "LT" "Continuous" "d" LOT 50" "" "LW" "0.50" "" "C" "20" "" ""))
)

 

Is that correct? if it's not, please tell me what I do wrong.Jamal Hatch Area2-in current units (1).dwg

HT2-HATCH AREA LEGEND CURRENT UNITS.LSP

Link to comment
Share on other sites

6 minutes ago, mhupp said:

I think we need a poem. but that might have more to do with bio fuel so i won't hold my breath.

I'll share with you a poem that written by me :) if you know turkish let's read together :D 

 

Sözcüklerle reddetsende beni kendinden

arkadamı dönüpte gidemiyorum ki senden

zifiri karanlık gecelerde amansız hasretinden

prangalar vurulur bana yüreğinden sürgünken

 

.

.

.

:D

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, PoetEngineer said:

I found a lisp for hatch area to table but there is a problem that is about description of layer. if you look at the file those I share with you then you'll see dwg file has like "LOT 50" etc. layer description. in addition when I using this lisp I can't see my hatch pattern. So what's wrong with my files. 

my second question is how can I create a layer with "LOT 50" description?

 

(setq b(command "-LAYER" "M" "____00-AF-MAHAL ÖLÇÜLENDİRME " "LT" "Continuous" "d" LOT 50" "" "LW" "0.50" "" "C" "20" "" ""))
)

Your lisp code appears to be missing a " before LOT 50" and has too many closing parenthesis ).

  • Like 1
Link to comment
Share on other sites

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