Jump to content

Change Layer Colour in 50+ Drawings


YZ

Recommended Posts

We have just worked out that the house lines in a series of diagrams blend in too much, and so I need to modify that layer's colour in order to plot thicker on our CTB file.

 

Three layers are affected: HOUSE, SHED & GARAGE.

 

They need to change from white to cyan.

 

There are almost 100 drawing files, mostly in the same folder.

 

Can someone tell me if this kind of repetitive task is one that a LISP routine could achieve? (Despite my profile I have access to full version in our office)

 

Thanks.

Link to comment
Share on other sites

Here's a vba routine I use in Excel:

 

Sub DbxEx()
Dim oDbx As AxDbDocument    'Add Reference to ObjectDbx Library
Dim fPath, fName As String
Dim oLay As AcadLayer
fPath = "C:\Documents and Settings\user\Desktop\New Folder\" 'Change Directory to Suit
fName = Dir(fPath & "*.dwg", vbNormal)
Do Until fName = ""
   Set oDbx = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument.17")  'Change to match Your Version

   oDbx.Open (fPath & fName)

   For Each oLay In oDbx.Layers
       If oLay.Name = "HOUSE" Or oLay.Name = "SHED" Or oLay.Name = "GARAGE" Then
           oLay.color = acWhite
       End If
   Next oLay

   oDbx.SaveAs (fPath & fName)

   Set oDbx = Nothing

   fName = Dir()

Loop
End Sub

 

ska

Link to comment
Share on other sites

a script file would do it as well, and is easier to write and run than trying to make a program to do it. However, that being said, we could do it in VBA or LISP, which ever you want

Link to comment
Share on other sites

I have the following Lisp routine that I want to apply to any DXF saved within a specified folder. I have located several BATCHing routines, but can't seem to fit it altogether. What was suggested about to create the VBA code above in a LISP routine would be great.

 

As of now, what I am doing is opening the file, and then clicking the button I created for the routine below. I got the routine to automaticaly save the file as a DWG (i don't want to replace the DXF file) and then close it. Thus leaving me to open the next DXF file manually.

 

Any thoughts?

 

(defun C:3dtrs (/ tfl tpth tfilnam tfilinfo)

(command "erase" (ssget "X" (list (cons 8 "ELEMENTS"))) "")

(command "_pedit" "M" (ssget "X") "" "y" "J" "" "")

(command "-purge" "La" "ELEMENTS" "N")

(command "_extrude" (ssget "X") "" "1.75" "")

(command "-view" "_left")

(command "rotate" (ssget "X") "" "0,0,0" "270")

(setq tfl (getvar "dwgname"))

(setq tpth (getvar "dwgprefix"))

(setq tfilnam (substr tfl 1 (- (strlen tfl) 4)))

(setq tfilinfo (strcat tpth tfilnam ".dwg"))

(command "saveas" "" tfilinfo)

(command "close")

(princ)

)

 

 

Thanks,

Robert

Link to comment
Share on other sites

Thanks ska.

 

a script file would do it as well, and is easier to write and run than trying to make a program to do it. However, that being said, we could do it in VBA or LISP, which ever you want

 

And thanks CmdrDuh. A script file would be fine. Forgive my ignorance, but I thought that was what a LISP routine was. So I might be using terms in a confusing way.

Link to comment
Share on other sites

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