Hey Guys,
I'm trying to set up an easy way to import layers from a certain dwt. file with a shortcut.
Now I found this code, which kind of works, but doesn't do the whole trick. It works with a Popup where I have to insert the dwt. file. It's also annoying that it opens this file than and I have to close it manually.
I would like to have this without any importoptions and automatically takes this one file always for the layers.
My file would be located here:
"I:\AutoCAD Blöcke\Template\__Bürostandard"
(defun c:IL (/ oAcad oCurDoc strFile oOpenDoc oOpenDocLayers lstObj oLayer array)
(setq oAcad (vlax-get-acad-object))
(setq oCurDoc (vla-get-ActiveDocument oAcad))
(setq strFile (getfiled "choose file:" (getvar "DWGPREFIX") "dwt" 0))
(setq oOpenDoc (vla-Open (vla-get-documents oAcad) strFile))
(setq oOpenDocLayers (vla-get-layers oOpenDoc))
(setq lstObj nil)
(vlax-for oLayer oOpenDocLayers (setq lstObj (cons oLayer lstObj)))
(setq array (vlax-make-safearray vlax-vbObject (cons 0 (1- (length lstObj)))))
(vlax-safearray-fill array lstObj)
(vla-CopyObjects oOpenDoc (vlax-make-variant array) (vla-get-Layers oCurDoc))
(princ)
)
I would be really thankful, if anybody could help me with this issue, cause I'm new to this LISP stuff any can't modify it on my own.
Thanks,
Klingi
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Consider my Steal from Drawing program, also available at the Exchange App Store.
Be sure to read the documentation for the program which explains how to configure the function to automatically import layers (and other objects) from a predetermined location, such as a template.
Ask if you have any questions!
Lee
For you case, you could create a custom command to call the Steal function in the following way:
(defun c:mysteal ( ) (Steal "I:\\AutoCAD Blöcke\\Template\\__Bürostandard.dwt" '(("Layers" ("*")))) )
The above will attempt to import all layers from the drawing: "I:\\AutoCAD Blöcke\\Template\\__Bürostandard.dwt"
Thx Lee,
you did it again.
saves me a lot of time and does exactly what it should and also my custom command works. was looking for that for a long time already.
cheers Klingi
You're most welcome Klingi - I'm delighted that you like the program!
Be sure to explore the full program, as it can import many more items than just layers
Lee
I tried your the plugin recently specifically for the layer states. However it did not work for me. I am wondering if it has something to do with new layers that were introduced in some of the nested xrefs. The only other thing that I tried is the UCS import which worked for me.
Also, I suspect after installing your plugin, it possibly changed one of ACAD's setting or something like that somewhere. The reason is that I have a separate lisp that i had no problem running before and all of the sudden stopped working. The lisp is fine as it still works on other users within the office. And between the time it worked/not working, the only change that I did to my ACAD is installing your plugin. I am attaching the lisp file for your reference. The lisp when added to the Startup Suite, will automatically etransmit and name any drawings that we open.
I know this is an old post, but I am wondering if the way to make this work is to create an additional lsp (defun c:mysteal) to call up the Steal lsp.
Or... can I just build that code into my toolpallete command such as:
^C^C_steal (Steal "C:\template.dwt" '(("Layers" ("*"))))
Note, this doesn't work for me. It just calls up the Steal lsp but I was hoping there was a way to automate the layer portion.
Can someone clarify? Thank you.
@Crass wrote:I know this is an old post, but I am wondering if the way to make this work is to create an additional lsp (defun c:mysteal) to call up the Steal lsp.
Or... can I just build that code into my toolpallete command such as:
^C^C_steal (Steal "C:\template.dwt" '(("Layers" ("*"))))
Note, this doesn't work for me. It just calls up the Steal lsp but I was hoping there was a way to automate the layer portion.
Can someone clarify? Thank you.
That should probable be
^C^C_steal (Steal "C:\\template.dwt" '(("Layers" ("*")))) or ^C^C_steal (Steal "C:/template.dwt" '(("Layers" ("*"))))
Look at post 3 and how the file string is constructed
I am not one of the robots you're looking for
Thanks for the reply. I guess that is my question. I am wondering how to activate the command. I tried entering Lee's file string in my tool palette command string but am not sure how to make this work. It doesn't even seem like the command string allows for multiple lines of text.
That should probable be
^C^C_steal (Steal "C:\\template.dwt" '(("Layers" ("*")))) or ^C^C_steal (Steal "C:/template.dwt" '(("Layers" ("*"))))
Look at post 3 and how the file string is constructed
I made the correction as you suggested but now my tool buttom just executes the Steal lisp. It doesn't carry out the layer import.
Thanks
Hi Lee - I am struggling with figuring out where exactly to enter the function arguments. I apologize for my ignorance on this. My goal is to create a number of tool pallete buttons. For example:
..., etc.
I just don't understand to run these through a tool palette command string. Or do I need to create separate discrete lsp files for each of these functions. A little guidance on this would be really helpful. Thank you!
Lee will answer how to use his program correctly but a suggestion this way you do not need to preload the steal lisp program.
^c^c(if (not steal)(Load "StealV1-6.lsp"))(steal ............)
Thanks for the reply.
@Sea-Haven wrote:
^c^c(if (not steal)(Load "StealV1-6.lsp"))(steal ............)
So this command will load the Steal lsp if the application is not already loaded or in the startup suite? This is useful. Thanks.