Showing posts with label AutoCAD Admin. Show all posts
Showing posts with label AutoCAD Admin. Show all posts

Thursday, January 15, 2015

Managing Trusted Locations in AutoCAD 2015

AutoCAD has a security feature to ensure that only code from Trusted Locations is loaded into your AutoCAD environment. "Code" includes LSP, DLL, MNL, FAS, ARX, DBX, JavaScript, and others.

There are a few System Variables to be aware of that might make it helpful to manage the Trusted Locations in your Environment.

First, the SECURELOAD System Variable. If this is set to 1 (Default setting), AutoCAD will load code based files only if their location is in the trusted locations specified in the TRUSTEDPATHS System Variable. If code based files are not in a trusted location, AutoCAD will display a warning.

If SECURELOAD is set to 0, AutoCAD will load code based files without warning (this is similar to previous versions of AutoCAD but is not recommended as it can put your environment at risk).

Second, the TRUSTEDPATHS System Variable. If SECURELOAD is enabled (i.e. set to 1) then trusted locations need to be specified in order to not have AutoCAD display a warning dialog every time a drawing is opened.

In this example I am trying to load an MNL file that is located in C:\SLD. The MNL file is calling LSP files that are in various support paths within the SLD folder.
This means that I receive a warning message for each file so I need to click Load 4 times to get to my drawing with my code loaded.

This can be resolved by specifying all of the folders as Trusted Locations in the TRUSTEDPATHS system variable.
Now when I open a drawing in this profile, the MNL and all of the supporting LSP files are loaded. This is nice but it is cumbersome to manage multiple support locations. For example, if a fourth Support folder is added to the environment I have to remember to add this as a Trusted Location.

Fortunately, there is a streamlined solution to this. If I want the SLD folder and all sub-folders to be trusted I can simply add \... (backslash and 3 dots) and just have 1 Trusted Location defined. So it would look like this:
Now all code based files within the C:\SLD structure will be loaded. This allows you to apply a level of security to your environment but not be overwhelmed by having to keep track of every location where a code based file exists.


Monday, August 25, 2014

Create an Application Plugin to automatically load custom content

There are several methods for loading custom content into AutoCAD. In other posts we have looked at partially loading CUI files and deploying a network based AutoCAD profile. Another method that is very streamlined and does not even require a custom profile is to use the ApplicationPlugins folder. Autodesk products automatically look in this location for content and will auto-load it if the content is properly organized. This feature was introduced in AutoCAD 2012 and can be a great way to deploy custom content.
The approach is quite different than other methods of managing custom content but it is very powerful as it is not attached to an AutoCAD user profile.
This post will walk through deploying a custom ribbon tab and command using the ApplicationPlugins folder. We will have all the usual pieces:
  • Some code to define the command
  • A CUI with icon images
Then the new component is an XML file that "bundles" the custom content together and tells AutoCAD how it should be loaded.

The location of the ApplicationPlugins folder is: C:\Program Files\Autodesk\ApplicationPlugins
Notice this is not specific to AutoCAD, Civil 3D, Map 3D, etc or even to a version. This is because all of these Autodesk products look in this location for content to load.

We will organize our content in this folder by first creating a top level folder to store our custom content and allow us to keep it separate from other plug-ins in this location.


The content can be organized in multiple sub-folders within this location. It can be setup to accommodate the custom app, or tools that are being added. For this example I made a few subfolders to store the application file (.dll), the CUI, and the images for the button.

 
 
Notice the PackageContents.xml file. This is what instructs AutoCAD on where the custom content is and ensures everything is loaded properly. Here is the contents of the XML file:

<?xml version="1.0" encoding="utf-8"?>

<ApplicationPackage SchemaVersion="1.0" AutodeskProduct="AutoCAD" ProductType="Application" Name="SLDexample" AppVersion="1.1.0" Description="Example Custom Content" Author="Streamlined Design"
                    AppNameSpace="" OnlineDocumentation=""
                    HelpFile="" Icon=""
                    ProductCode="SLD0001" UpgradeCode="">

  <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD*|AutoCAD" SeriesMin="R18.2" SeriesMax="R19.1"/>

  <CompanyDetails Name="Streamlined Design" Url="http://streamlined-design.blogspot.com" Email=" " />

  <Components>
    <RuntimeRequirements SupportPath="./Contents/Support" OS="Win32|Win64" Platform="AutoCAD*|AutoCAD" SeriesMin="R18.2" SeriesMax="R19.1"/>

    <ComponentEntry AppName="SLDexample" Version="1.1.0" ModuleName="./Contents/SLDexample.dll" AppDescription="SLD Custom Command" PerDocument="True">

      <Commands>
        <Command Local="SLDappPlugin" Global="SLDappPlugin" Description="Custom Command Using Plugin" />
      </Commands>
    </ComponentEntry>
 
    <ComponentEntry AppName="SLDexample" Version="1.1.0" ModuleName="./Contents/Support/SLDexample.cuix" AppDescription="SLD Tools CUI" />

  </Components>
</ApplicationPackage>

The first part of this file defines the application. There are a few fields that can be left blank and the ProductCode can be a unique identifier.
<ApplicationPackage SchemaVersion="1.0" AutodeskProduct="AutoCAD" ProductType="Application" Name="SLDexample" AppVersion="1.1.0" Description="Example Custom Content" Author="Streamlined Design"
AppNameSpace="" OnlineDocumentation=""
HelpFile="" Icon=""
ProductCode="SLD0001" UpgradeCode="">
 
The <Components> section is where a SupportPath can be defined, this creates a functioning support path while AutoCAD is running. The OS and AutoCAD versions can be specified as well.
<Components>
<RuntimeRequirements SupportPath="./Contents/Support" OS="Win32|Win64" Platform="AutoCAD*|AutoCAD" SeriesMin="R18.2" SeriesMax="R19.1"/>
 
There is a <ComponentEntry> for the application (.dll in this example) as well as for the CUI. Notice each component is pathed to using a relative path location from the folder the XML file is located in. This is represented by the "." in the path.
<ComponentEntry AppName="SLDexample" Version="1.1.0" ModuleName="./Contents/SLDexample.dll" AppDescription="SLD Custom Command" PerDocument="True">
 
Each command defined within the application file (.dll) should be specified. In this example there is only one command: SLDappPlugin. If there were more each one would have its own line:
<Command Local="SLDappPlugin" Global="SLDappPlugin" Description="Custom Command Using Plugin" />
 
After defining the application file and the commands the CUI is defined also as a <ComponentEntry>
Again, a relative path location is used from the XML file to the location of the cui file.
<ComponentEntry AppName="SLDexample" Version="1.1.0" ModuleName="./Contents/Support/SLDexample.cuix" AppDescription="SLD Tools CUI" />
 
With the XML file pointing to the application and cui file it is now ready for AutoCAD to load. There is nothing additional required on the AutoCAD side, simply ensure the bundle folder is directly in the ApplicationPlugins folder mentioned above and then launch AutoCAD.
 
You will notice an information bubble pop-up that confirms the custom application was loaded properly

The CUI elements defined in the CUI should now be available

And the command definition in the .dll will be active

Also, without any additional configuration this plugin is available in Civil 3D since it also auto-loads from the same ApplicationPlugins folder.

 
This opens up a whole new method of managing custom content. Consider an automated method of deploying this content to workstations with a batch file and/or SharePoint.


 

Thursday, May 9, 2013

Create a custom ribbon tab using the custom CUI

In a post last week we looked at reasons the custom.cui can be a great spot for users to create their own custom AutoCAD content. After some feedback I am realizing it would be helpful to walk through creating a custom element from scratch and having that load from the custom.cui.

As mentioned, the custom.cui is partially loaded into the acad.cui by default.
Creating CUI elements in here is the same process as in the acad.cui. Expand the Custom CUI node and locate the type of element you want to add. For this example we will:
  • Create a new Ribbon Tab
  • Create a new Ribbon Panel
  • Create a custom command to add to the Panel
  • Make sure the new Ribbon Tab is available in your AutoCAD environment
Create a new Ribbon Tab by right clicking on the Tabs element and select New Tab.
 
Give the new tab a name and it will now be displayed in Custom, Ribbon, Tabs.
Next, create a new Panel that will be added to the tab. Remember, a Tab can host multiple panels. We will just create one panel for this exercise. To create the new Panel, right click on the Panels element and select New Panel.
Give the new panel a name and it will now be displayed in Custom, Ribbon, Panels.
Let's define a custom command that we can add to our new panel. Click the Create a new command button and a new command will be added to the Command List pane in the CUI Editor. Give the new command a name.
Once the command is created we can define what the command should do. This example is a custom command that is defined in an external file (either Lisp or dll). As long as this file is loaded through the custom.mnl then it will be loaded in the drawing.
Now that our command is created we can add it to our custom panel. To do this drag the command up to the panel location where the command should be. Note: if you drag the command to the left (off the CUI dialog) then move your mouse up to where the panel is before bringing the mouse back over the CUI dialog this will prevent any scrolling that can happen if you try to drag the command straight up.
After adding the command to the Ribbon Panel there are some properties that you may want to adjust for how it displays on the actual panel. This gets into the layout of the CUI Ribbon Elements but for this example I am selecting the large icon with text option.
Now that we have a custom command and a custom ribbon panel, we need to add the panel to the custom Ribbon Tab. To do this just drag the panel onto the tab.
Lastly, we need to make this Ribbon Tab available in AutoCAD. If the custom Ribbon Tab that was created does not automatically show up in AutoCAD this will be controlled by the active workspace. To turn the custom Ribbon Tab on in the active workspace click Customize Workspace (in the CUI dialog)
 
then scroll down to the Partial Customization Files and locate the Custom Ribbon Tab. Check the box next to this element.
Click Done to finish Customizing the workspace and then Apply the CUI changes.
The new tab, panel, and command should now be available in AutoCAD.
 
You will also notice after doing this that the custom command now exists in the Custom menu source in the CUI Command List.
 
By creating this structure this allows users to create multiple custom commands and panels and easily transport them to a new workstation or a new version of AutoCAD just by bringing the custom.cuix file (and associated mnl, lisps, dll's, etc.) along with it.
 
One approach could be to create a Custom subfolder in the same folder where the custom.cuix and custom.mnl are located. Custom code can be stored in this folder as well as the icons for the ribbon panels.


 

 


 

 

 


 
 

 

Thursday, May 2, 2013

Use Dropbox to deploy a network based AutoCAD environment

Managing an AutoCAD environment from a single source on a shared network server has several benefits. Delivering consistent standards, customizations, and more, to multiple users is the goal of a streamlined AutoCAD environment.

With recent technology trends and so much movement towards the cloud, new opportunities are becoming available. Without the expense of purchasing, building, and maintaining an enterprise network, Dropbox provides a free cloud based solution that can reach all around the globe. Dropbox is free to setup and you will instantly have plenty of storage capacity for an entire AutoCAD environment (and more).

To combine the power of Dropbox with the flexibility of AutoCAD it will require installing the desktop version of Dropbox (not just using the web based interface). Also, it is important to use the default install path for Dropbox (C:\Users\...\Dropbox). Otherwise, as you will soon see we would not be able to share content with multiple users.

Dropbox functions exactly like any other folder on your computer except that when you are connected to the Internet it will synch with your Dropbox folder in the cloud. This allows you to have access to all of your content whether you are offline or online. You can create as many subfolders in your Dropbox folder as you would like and those folders can be shared with other Dropbox users.

If Dropbox is installed in the default location as mentioned above it can be accessed through the windows system variable %UserProfileFolder%. This means we can customize our AutoCAD based user profile using "%UserProfileFolder%\Dropbox\shared folder name". This path will resolve to everyones' Dropbox folder and allow the AutoCAD profile to load properly. Note: In order for everyone to synch to the same folder the folder must be shared by the original creator.

Here is an example of a custom profile that loads an Enterprise Menu File (which of course also loads an .mnl with the same name and in the same location) from Dropbox, changes the plot style path to a location on Dropbox, and adds a support path to Dropbox.


This sets the stage to do pretty much anything you want with an AutoCAD profile. When this profile is loaded into AutoCAD the paths above resolve to each individual user's Dropbox location which is synched from the master folder that was originally shared from Dropbox (Note: only the SLD subfolder in this example is shared, not the entire Dropbox folder).
 
Using Dropbox to manage an AutoCAD environment allows a lot of possibilities. If a team is spread out across the globe Dropbox will keep them in synch. Also, it does not require an Internet connection so team members can work offline (as long as they were connected initially to receive the content from Dropbox). The next time they connect to the Internet Dropbox will automatically update their folder with any new content from the master folder in the cloud. Another point to reiterate is that everyone is always accessing content from their local C:\ drive which is quick and efficient regardless of location.
 
This post focuses on managing an AutoCAD environment within Dropbox, but of course working drawing files can be stored there too.






Wednesday, May 1, 2013

Automatically create PDF or DWF files from AutoCAD

As electronic drawing formats (PDF and DWF) are becoming more popular both for internal checks during the design process and even final deliverables, it is important to have good workflows for this. A very handy feature for creating PDF and DWF files (that in my experience seems to be fairly unknown) is Auto Publish.
Auto Publish is found on the Plot and Publish tab in the options dialog.

There are quite a few options available in the Auto Publish Settings dialog. Some of the key ones are:
  • Publish on Close, Save, or to prompt before publishing
  • Choosing the file format, PDF or DWF
  • Single-Sheet or Multi-Sheet
  • The output location. Drawing Folder creates the file in the same folder the drawing is in. A full path could be provided here as well. Note: these settings are stored in the registry so this path can be added to a network based profile so multiple workstations output to the same location.

Once the preferred settings are made the Auto Publish needs to be toggled on before it will be in effect.

In my settings I chose to publish a PDF when I close my drawing file. I also specified the location to be the Drawing Folder. With these settings in place and the Automatic Publish toggled on when I close my drawing a PDF is automatically created.

Notice the layout tab name is added to the filename just like when publishing directly from AutoCAD. In the future the PDF will automatically be overwritten when I close the file again.

Auto Publish is a very flexible feature and the settings are stored in the AutoCAD profile which makes it great for managing a network based AutoCAD environment. The Automatic Publish toggle is off by default and there is not a registry key for this state. When the toggle is on and if you want to force it to be on through the AutoCAD profile here is the registry key for that (in the General section of the registry)
"AUTOMATICPUB"=dword:00000001

The Auto Publish settings are also stored in the AutoCAD profile in the AcAutoPublishOpts section of the registry.

Take some time to explore all of the options with Auto Publish, this can offer several streamlined workflows to the design environment.