Author Topic: Importing Layer controls without opening drawings  (Read 10260 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Importing Layer controls without opening drawings
« on: July 08, 2014, 01:46:24 PM »
I was wondering if there is a possible way for a user to select certain drawings within the same directory (folder) and inject a new layer with its color without the user having to physically open each drawing and creating them?

Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Importing Layer controls without opening drawings
« Reply #1 on: July 08, 2014, 01:52:14 PM »
Download & load my ObjectDBX Wrapper function & Get Files Dialog function, and then try the following code:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / lst )
  2.     (if (setq lst (LM:getfiles "Select drawings to process" "" "dwg;dwt;dws"))
  3.         (LM:odbx '(lambda ( doc ) (vla-put-color (vla-add (vla-get-layers doc) "MyLayer") acred)) lst t)
  4.     )
  5.     (princ)
  6. )

The above will create a red layer called "MyLayer" in selected drawings, or will make this layer red if it already exists.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Importing Layer controls without opening drawings
« Reply #2 on: July 08, 2014, 02:01:17 PM »
Geesh! Wow! I have a user who is not very tech savvy. How can I get them to use this?
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Importing Layer controls without opening drawings
« Reply #3 on: July 08, 2014, 02:02:18 PM »
Geesh! Wow! I have a user who is not very tech savvy. How can I get them to use this?

Show them how to use it?

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Importing Layer controls without opening drawings
« Reply #4 on: July 08, 2014, 02:05:15 PM »
I can definitely try too. I guess I was thinking that there would be a way that the user can launch the command, pops up a box to select what files and then prompt what layer name and color to use.
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Importing Layer controls without opening drawings
« Reply #5 on: July 08, 2014, 02:12:10 PM »
I guess I was thinking that there would be a way that the user can launch the command, pops up a box to select what files and then prompt what layer name and color to use.

Yes, this is possible -
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / col lay lst )
  2.     (while (not (or (= "" (setq lay (getstring t "\nSpecify layer name: "))) (snvalid lay)))
  3.         (princ "\nInvalid layer name.")
  4.     )
  5.     (if (and (/= "" lay)
  6.              (setq col (acad_colordlg 7 nil))
  7.              (setq lst (LM:getfiles "Select drawings to process" "" "dwg;dwt;dws"))
  8.         )
  9.         (LM:odbx '(lambda ( doc ) (vla-put-color (vla-add (vla-get-layers doc) lay) col)) lst t)
  10.     )
  11.     (princ)
  12. )

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Importing Layer controls without opening drawings
« Reply #6 on: July 08, 2014, 02:44:52 PM »
I will give it a try!
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Importing Layer controls without opening drawings
« Reply #7 on: July 08, 2014, 04:14:44 PM »
Ok. I am having a problem. I can not figure out how to run your lisp! lol (sorry)!
Civil3D 2020

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Importing Layer controls without opening drawings
« Reply #8 on: July 09, 2014, 01:59:37 AM »
Ok. I am having a problem. I can not figure out how to run your lisp! lol (sorry)!
Did you do this also?
Download & load my ObjectDBX Wrapper function & Get Files Dialog function...
You'd need both those in addition to Lee's code, since it's calling those 2 functions. Thus you'd have to load those functions as well, or simply paste all of them into the same LSP file.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Importing Layer controls without opening drawings
« Reply #9 on: July 09, 2014, 03:17:19 AM »
Find attached

duotu007

  • Guest
Re: Importing Layer controls without opening drawings
« Reply #10 on: July 10, 2014, 04:13:33 AM »
I guess I was thinking that there would be a way that the user can launch the command, pops up a box to select what files and then prompt what layer name and color to use.

Yes, this is possible -
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / col lay lst )
  2.     (while (not (or (= "" (setq lay (getstring t "\nSpecify layer name: "))) (snvalid lay)))
  3.         (princ "\nInvalid layer name.")
  4.     )
  5.     (if (and (/= "" lay)
  6.              (setq col (acad_colordlg 7 nil))
  7.              (setq lst (LM:getfiles "Select drawings to process" "" "dwg;dwt;dws"))
  8.         )
  9.         (LM:odbx '(lambda ( doc ) (vla-put-color (vla-add (vla-get-layers doc) lay) col)) lst t)
  10.     )
  11.     (princ)
  12. )
hi,LM,some fun like vla-purgeall  vla-zoomextents can't work with ObjectDBX?

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Importing Layer controls without opening drawings
« Reply #11 on: July 10, 2014, 07:30:26 AM »
Thank you all for your help! Just another dumb question to go with this... Is there a way to run another lisp inside or script file? If not that's ok. Just curious!
Civil3D 2020

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Importing Layer controls without opening drawings
« Reply #12 on: July 10, 2014, 07:40:20 AM »
yes. just load it from the scoipt and call it.

Have a play.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Importing Layer controls without opening drawings
« Reply #13 on: July 10, 2014, 01:38:16 PM »
@Irné & Hasan, thank you for assisting in my absence.  :-)

@duotu007, only ActiveX methods derived from the document object will be available from ObjectDBX, and even then there are limitations. Since zoomextents is a method of the application, this certainly cannot be used, but I have not tried the purgeall method through an ObjectDBX interface - let me know how you get on.  ;-)

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Importing Layer controls without opening drawings
« Reply #14 on: July 10, 2014, 01:45:40 PM »
I guess I was thinking that there would be a way that the user can launch the command, pops up a box to select what files and then prompt what layer name and color to use.

Yes, this is possible -
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / col lay lst )
  2.     (while (not (or (= "" (setq lay (getstring t "\nSpecify layer name: "))) (snvalid lay)))
  3.         (princ "\nInvalid layer name.")
  4.     )
  5.     (if (and (/= "" lay)
  6.              (setq col (acad_colordlg 7 nil))
  7.              (setq lst (LM:getfiles "Select drawings to process" "" "dwg;dwt;dws"))
  8.         )
  9.         (LM:odbx '(lambda ( doc ) (vla-put-color (vla-add (vla-get-layers doc) lay) col)) lst t)
  10.     )
  11.     (princ)
  12. )
hi,LM,some fun like vla-purgeall  vla-zoomextents can't work with ObjectDBX?


I have been working on this for a few... no such luck with calling a script. However, this is pretty powerful stuff!:)
The script is on my C root drive...
Civil3D 2020