Jump to content

Recommended Posts

Posted

Below is a collection of lisp about Entmake line type: (ent-Linetype "LINE_1" "Created by entmake" '("A" 0.7 -0.7)) "- - - - - - - - "

Now I want to edit it to Entmake line type that contains text, shaped like: "- - DN  - -  DN - -  DN - - "

Hoping for help me. Thanks!

(defun ent-Linetype  (name description param-list)
  (entmake
    (append
      (list '(0 . "LTYPE")
            '(100 . "AcDbSymbolTableRecord")
            '(100 . "AcDbLinetypeTableRecord")
            (cons 2 name)
            '(70 . 0)
            (cons 3 description)
            (cons 72 (ascii (nth 0 param-list)))
            (cons 73 (- (length param-list) 1))
            (cons 40 (apply '+ (mapcar 'abs (cdr param-list)))))
      (apply 'append
             (mapcar '(lambda (x) (list (cons 49 x) '(74 . 0)))
                     (cdr param-list))))))

 

Posted (edited)

A linetype can be read from a .lin file no need for code.

 

*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----
A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08

 

We had custom.lin with lots of linetypes and would preload into our dwt so ready to go. Or Linetype Load 1 or more linetype into a dwg.

 

;load missing linetypes
;;; returns: T if loaded else nil
(loadLinetype doc "Fence" "custom.lin")
(loadLinetype doc "Tree" "custom.lin")

 

(setq  doc (vla-get-activedocument (vlax-get-acad-object))) ; open database

(defun loadLinetype (doc LineTypeName FileName)
  (if (and
        (not (existLinetype doc LineTypeName))
        (vl-catch-all-error-p
          (vl-catch-all-apply
            'vla-load
            (list
              (vla-get-Linetypes doc)
              LineTypeName
              FileName
            )
          )
        )
      )
    nil
    T
  )
)

(defun existLinetype (doc LineTypeName / item loaded)
  (vlax-for item (vla-get-linetypes doc)
    (if (= (strcase (vla-get-name item)) (strcase LineTypeName))
      (setq loaded T)
    )
  )
)

 

Edited by BIGAL
  • Like 2
Posted

I thought I'd made this one up but no, to create a line type 'on the fly' I was going to create a temporary .lin file (same as writing to a text file, just save as '.lin') and load from there.... but I haven't needed that yet, not made it up yet.

Posted (edited)

@Steven P if you use "A" append option for a file then can add a new linetype to a "lin' file, would check 1st does name exist ?

Edited by BIGAL
  • Like 1
Posted

If I was doing that I'd also want to check that the line type name wasn't existing in the file... could be 'on the fly' is the same name but a different definition - not a big issue or one that would happen often I reckon

  • Like 1

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