Jump to content

Recommended Posts

Posted

Hello. How can I check if the line type "TRAZOS" is loaded? And if it is not charged, how can I charge it? Thank you

Posted (edited)

Something like this:

 

Linetype is the line name "TRAZOS" (I don't think it i case sensitive)

 

acad.lin is the line definition file that the line type is described in - you might need to find out what that is and replace the text below assumes here that the file 'acad.lin' is in trusted files location

 

 

  (defun MakeLoadLines ( linetype / )
    (if (tblsearch "LTYPE" linetype)                                   ;;Check if linetype is loaded
      (command ".-linetype" "_Load" linetype "acad.lin" "_Yes" "")     ;; reload it anyway. Replace with (progn ) for no reloading
      (command ".-linetype" "_Load" linetype "acad.lin" "")            ;; otherwise load it
    )
    (princ)
  )

 

Edited by Steven P
  • Like 2
Posted

Thank you so much, steven It works perfectly.

  • Like 1
Posted

We have Custom.lin, MCC-Services.lin, DRAINPIPE.LIN, plus more custom linetypes.

 

Just type "linetype" and look it shows what is loaded, select another file and can choose "TRAZOS". Side note yes can load linetype "TRAZOS" from a custom.lin file if its not already loaded.

 

 

(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)
    )
  )
)


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

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

 

  • Like 1
Posted

Thank you very much Bigal. It's perfect!!!

Posted

I noticed a small mistake in the existLineType function.

It only returns true if the last found linetype is the one you are looking for, but if you change it to this it should work as expected:

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

The code is cut from a big program so loaded is checked further down in the code no need for extra "loaded" it returns T or nil.

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