A friend of mine just asked me how to do it, this is one simplistic answer --
(defun LoadLineTypes ( lineTypeSpec lineTypeFileName / result )
(if (findfile lineTypeFileName)
(vl-catch-all-apply
'(lambda ( )
(vla-load
(vla-get-linetypes
(vla-get-activedocument
(vlax-get-acad-object)
)
)
lineTypeSpec
lineTypeFileName
)
(setq result t)
)
)
)
result
)
If the the linetype already exists in the drawing or the specified linetype doesn't exist in the linetype definition file or said file doesn't exist / is corrupt the function will return nil. Accordingly, the function will return t on a successful load. As such, the caller may wish to some some preprocessing / prequalification before invoking if they wish for the calling logic to branch appropriately.
While one could be more ambitious and perform all the noted scan / prequalifications I opted to keep it lean and mean per the original inquirey.
Example use --
(LoadLineTypes "continuous" "acad.lin")
Returns nil because "continuous" is already defined in drawing.
Assuming linetype "hidden" doesn't exist in drawing and is defined in acad.lin --
(LoadLineTypes "hidden" "acad.lin")
Returns t.
A second call --
(LoadLineTypes "hidden" "acad.lin")
Returns nil because the "hidden" linetype is already defined.
If all linetypes are purged from drawing, then this call (which uses the wild carding) --
(LoadLineTypes "*" "acad.lin")
Returns t the first time it's invoked, nil thereafter (all things remaining constant) for the reasons noted above.
Cheers.