PDA

View Full Version : VBA code - Open all autocad files from a folder do some standard changes and save file to the new folder



vishal.mahajan691208
2015-07-15, 09:11 AM
Hi,

I am using AutoCAD 2015. I have a requirement where i have more than 500 AutoCAD files (.DWG) which are kept in the folders in a structured manner (Multiple folder under one folder). I want to do some font changes (same for all file) to all files and want to save the file. I have seen some code which do the same thing for .DXF but i haven't found anything for .DWG.
Can someone please help me with a VBA code where all these ativities can be done on one click? I have the code to do font changes as mentioned below which can be applied to each file. Please let me know if more information needed.

Thank in advance for the help. Your help is greatly appreciated.


Public Sub ChangeFonts()
Dim TextFont As AcadTextStyle
For Each TextFont In ThisDrawing.TextStyles
TextFont.fontFile = "C:\Windows\Fonts\Romans.shx"
TextFont.Height = "0.8"
TextFont.Width = "0.75"
TextFont.ObliqueAngle = "0"
Next TextFont
ThisDrawing.Regen acAllViewports
End Sub

Ed Jobe
2015-07-15, 06:38 PM
I recommend using ScriptPro to run a script on the files. It takes care of handling the files. You can download it here (http://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/autodesk-customization-conversion-tools.html). Then all you need is a script. You write that in Notepad. You can use the VBARUN command to call your sub.