Showing posts with label folder. Show all posts
Showing posts with label folder. Show all posts

Thursday, 31 July 2014

Locate folder for iLogic save as

Our design office uses vault for backup and history but the rest of the engineering department has it’s own folder on a mapped network drive. That’s where you’ll find contract specific files, as well as images, schedules, emails and literally anything that the project needs.
                So once a drawing is approved we get to release it to the engineering shared folder and need to place it in the project specific folders for dwf’s and pdf’s.
                This is a typical structure on the network of the engineering folder.
Root folder:
G:\Commercial & Engineering\Engineering\Contracts
where we have
105280-Pharmaceutical
105281-Industrial
105282-Scientific
105283-Healthcare
105285-Scotland

each split in hundreds for better navigation  by contract number:
001-099
100-199
200-299
                then we go project number and then drawing folder and pdf folder.
G:\Commercial & Engineering\Engineering\Contracts\105281-Industrial\100-199\105281109 – Project Description\Drawing\PDF
                My task was to create/modify existing ilogic to save current drawing as dwf and pdf each in it’s folder on the G drive.

                Here’s the code I came up with:

' set the filepath of the contracts folder to start with.
strStartFolder = "G:\Commercial & Engineering\Engineering\Contracts\"
' get the filename without extension 
oFileName = ThisDoc.FileName(False)   
' get the project type by reading the first 
'6 digits of the filename EX 105280 or 105281 
strFolderType = ( Left (oFileName,6))  
' get the last 3 digits of the project no start 
'after first 7 digits of filename Ex 005 or 109 
strFolderNo = (Mid (oFileName,7, 3))  
'get the first 9 digits to compose project type 
'and number Ex 105281005 or 105281109 
strFolderProj = ( Left (oFileName,9))  
'get the document revision to use in the new filename 
oRevNum = iProperties.Value("Project", "Revision Number") 

'Set folder for project based on Contract No
If strFolderNo < "100" Then
strFolder3 = "\001-099\"
ElseIf strFolderNo >= "100" Then
strFolder3 = "\100-199\"
ElseIf strFolderNo >= "200" Then
strFolder3 = "\200-299\"
End If

'Find folder in start path that contains Folder Type string 
Dim dir1() As String = System.IO.Directory.GetDirectories _
(strStartFolder, strFolderType & "*")
'Add Contract No folder to our folder
Dim dir2 As String = String.Concat(dir1) & strFolder3

'Find folder in new path containing Folder Type 
Dim dir3() As String = System.IO.Directory.GetDirectories _
 (dir2, strFolderProj & "*")
'Add Drawing folder to our path
dir4 = String.Concat(dir3) & "\Drawing\"

'set name for the new files, adding revision to end
strNameDWF = dir4 & oFileName & "_Rev" & oRevNum
strNamePDF = dir4 & "PDF\" & oFileName & "_Rev" & oRevNum

'Do the save operation
ThisDoc.Document.SaveAs(strNameDWF & (".dwf") , True)
ThisDoc.Document.SaveAs(strNamePDF & (".pdf") , True)

MessageBox.Show("All file formats saved in: " & dir4, "File Save")



                Hope it makes sense; I did struggle with the code ( I am not a programmer) but Curtis Waguespack's website was inspiring.

ADS

Thursday, 10 July 2014

AutoCAD advanced search replace

A couple of words on Autocad search replace. Autocad has the functionality built in and for simple things is good enough.
For example when I need to change pipe size on a P&I D I can select the labels and use the properties (CTRL+1) to change the attribute text all at once.

If you need to change different types of notes, blocks, texts, multiline-text etc. then you can use the Search/Replace functionality

You can search in Entire drawing / Current space/layout or in selection (pre selected object or on the spot)

On the result list you can select just part of the items before doing replace.

But what if you need to do a complex search replace? This won’t do.
I had to change Cable Schedule in several acad drawings and all I was given was an excel file.  Luckily I had the previous revision of the excel file and I could make a list of old - new name. Lee Mac has created a script that can do that for you. The script is called BFind and here’s how I used it.
                 This is what the Acad looks like.
                 And this is what we will end up with.


Once you load the BFindV2-0.lsp script in you acad session (you can drag drop it on your drawing) run it by typing BFind and you should get the following window.


In here you can search replace in current drawing, all open drawings, folder,  folder with subfolders. You don’t want to type all text changes one at a time but rather use a text document with the values from excel so here’s how to do that.
You need to add something in the search replace fields and save it as a text for reuse late. You can then open the reuse text document and add your texts. Load it back in the BFind window an hit ok.

Let’s add Find: ADS ad Replace with: ADS1 then click Save. Click OK for changes to take effect and then open windows explorer and let’s locate the file.  Do a search on C: drive for a file name that contains LMAC BFind. Mine was located here:
C:\Users\adrian.salariu\AppData\Roaming\Autodesk\AutoCAD Mechanical 2015\R20.0\enu\Support\LMAC_BFind_SavedSearches_V2-0.txt
Open it up and check to make sure it contains our saved Search Items List.



Add your text in and save the document. In Autocad run BFind and click on Load to load your list.
After selecting your search location (drawing, folder , etc.) click OK and go get a coffee till it’s done.

This saved me a couple of hours of boring, mind-numbing work. Hope it helps you as well. Here's the link to Lee's web page.


ADS