LISP: can you reload a linetype using vla-load?
I get an Automation Error if I use this code in a drawing that already has a linetype hidden2:
(vla-load (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object))) "hidden2" "iso.lin")
Comments
-
Dear Roy,
as I also verified this with AutoCAD behaviour, if a linetype is already present,
it correctly throws a COM error (duplicate record name).You can verify whether it exists :
(if (not (tblobjname "LTYPE" ltypename)) (vla-load .....))
But this does not a true reload ... COM does not support this, unfortunately;
so only solution is to use (command ...) for a true reload ... (vla-load) is fine
for initial load.
Many greetings, Torsten0 -
Hi Roy, Hi Torsten,
Would this not work?:
(if (tblobjname "LTYPE" ltypename)
(vla-delete(vlax-ename->vla-object(tblobjname "LTYPE" ltypename)))
)
(vla-load (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object))) ltypename "iso.lin")Kind regards,
Stephan
0 -
I think trying to delete the line type then reload it might cause problems with layers and other entities already assigned the line type... be right back...
Ok, for my quick test (v11.1.14) it does cause a problem, audit reports invalid linetypes and the fix is to set the layer to continuous and the entity to by-layer.
Not sure what the other cad does...
0 -
Dear All,
I also agree with Greg - deleting the linetype will cause problems,
even if that deleted one is loaded a moment later ... during deleting
the linetype, those dependencies are changes, thus even a later re-reload
will cause those entities not to use it ...
Many greeitngs, Torsten0 -
@ Torsten, Stephan and Greg:
Many thanks for your answers!0 -
You both are right. I forgot that I have to expect the linetypes to be referenced by drawing elements.
But in order for me to contribute something useful, I build on your comment, Torsten:
(if (tblobjname "LTYPE" ltypename)
(command "_.-linetype" "_l" ltypename "<path to support folder>\\iso.lin" "_y" "")
)
0