by Mark Stefanchuk, CADmanage.com
Seth’s last blog, Resources Resources…, was great! In particular this bit of information really caught my attention.
The Files tab lists the folders that AutoCAD will use to search for resource files (a.k.a. Support Paths), drivers, CUI files, tool palettes, and so on. There are also user-defined settings such as the dictionary file used for checking spelling. Paths are searched in the order that they are listed in the Options dialog box, and if the same file exists in different folders, the first instance found is used.
Ok, so that got me thinking. How do I know if there is more than one file with the same name in my paths folders and is the file I want loaded in the right place? My first thought was to just look in each folder and see if there are duplicates. But, turns out there are a lot of files in these folders. I’m going to need a better way. I could write a vb script to look in each support folder and compare all of the files dumping the results to some output file, but I kind of want to be able to debug my profile folders when I’m in AutoCAD. To do that we will need a different approach.
I decided to build a plug-in. If you’re not familiar with .Net plugins for AutoCAD check out Autodesks “My First Plug-in” tutorials. Really well done. You don’t need the wizard, and you can find the AutoCAD references in the AutoCAD program files folder. There are a lot of on-line tutorials for VB.Net or C# – either programming language can be used to create an AutoCAD plugin. I’ll let you do your own googling to find what you need.
Here are some pointers for getting the support file information from AutoCAD. We will start by just figuring out what our support files are.
Your class will need to reference and Import the following:
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.Interop
In your class you will need a new command to show the support paths.
<CommandMethod("SHOWSP")> _ Public Shared Sub ShowSupPaths() Dim acadApp As AcadApplication = Application.AcadApplication MsgBox(acadApp.Preferences.Files.SupportPath) End Sub
Compile this to create a dll that you can netload (just like in the plug-in tutorials). After you netload you can use the command SHOWSP which will display a message box similar to this one.
It’s not very pretty and you can find the same information using the built in OP (options) command. So, what we really want is to get a list of file names from each folder and then compare them to one another to see if they show up more than once. What can we do? The first thing to notice is that the support paths are separated by a semi-colon. That gives us a way to “split” the string into an array of folders. We can then use System.IO to get directory info which we can use to list the file names. Something like this…
Dim sPaths() As String sPaths = acadApp.Preferences.Files.SupportPath.Split(";") For Each s As String In sPaths Dim di As DirectoryInfo = New DirectoryInfo(s + "\") For Each f As FileInfo In di.GetFiles() lstFiles.Items.Add(f.Name) Next Next
In this example I have added the file names to a list box. You can loop through the list items to check for duplicates and output to another list box. I took it a step further and built a Palette. In the top panel I added a tree view so that I have a way to step though the folders and files. In the bottom panel I list the files that show up more than once.
I also added a double click feature to open a window and select the file in the folder it resides in so that I have a quick way to compare files. Finally, I decided to add an extension filter so that I can debug just cuix, or lsp files.
We’re looking into posting this on the Autodesk Exchange. So, if you don’t want to dig deeper and try to write it yourself I hope to have this submitted and available in the next few weeks.
About Mark Stefanchuk: Mark is a VP and senior consultant with CAD Management Resources, Inc. He divides his time between developing innovative custom software solutions and helping clients navigate complex design automation environments. If you would like to find out how he can assist you with your design technology he can be reached by contacting us at firstname.lastname@example.org.
by Seth Cohen, CADmanage.com
When using CAD, you need to know what resources to use, and how CAD “finds” those resources. CAD, is not like Word or Excel, and requires resource management at a much higher level. So what are resources, and how do you find them. Well, resources are items like blocks (cells), linetypes (linestyles), layers (levels), text styles, etc. How do you find resources, well that’s a tough question to answer and depends on many variables such as the client or company your work for. Ask your CAD manager or the client you are working for to get a good grasp as to the resources you will need to use. In this article, let’s look at AutoCAD and how it finds resources to make them available to you.
In AutoCAD, you use an AutoCAD Profile to point to your resources and define settings. To view/define the current AutoCAD profile, right-click in the drawing view and choose Options from the shortcut menu (or type OP in the command line).
In the image below, I am in an AutoCAD profile using the Ford Motor Company standards.
A quick little tip to having AutoCAD load the desired AutoCAD profile automatically is to use a command line parameter. To do so, first, in AutoCAD, click the Export button on the Options dialog box, and save the .ARG file (AutoCAD Registry File) to a location on your server for other users to access. Next, copy the default AutoCAD icon, and rename it to something that is related to the standards that you will be using. Next, right-click on the icon and choose Properties from the shortcut menu. In the Target field, at the end of all the paths defined in it, type /p <the path to the .ARG file>. Note, the first time AutoCAD does this will be the only time it loads the profile file. If you update the .ARG file on the server, it does not automatically update the AutoCAD profile. You will need to physically delete it from the Options dialog box and reload it through the icon.
We will discuss other ways to access your resources in future posts, and talk more of the things you can set in the Options dialog box.
“Now you know, and knowing is half the battle.” …………G.I. Joe
by Lorrie Mattor, CADmanage.com
Create help files for any command within CadPilot menus!
If a Help File command is associated with the menu icon then the cursor will appear as a hand while floating over the menu icon. When the icon is selected the Help file will open. To execute the menu command simply slide your cursor over the command text until the cursor displays as an Arrow.
There may be times when a Help file is not associated with the Menu icon, in these cases the cursor will be displayed as an Arrow and the Menu command will be issued (even when selecting the icon).
If your command does not have a help file associated with it and you feel it would be helpful, contact your CadPilot Administrator (Cad Manager) to add it to the CadPilot menu.
Lorrie is a Technical Consultant for CADmanage.com specializing in CadPilot integration, system’s analysis, technical writing and data manipulation.