This post is for all Autodesk Inventor Users. How many times have you felt the need to take a screenshot of your Inventor file (assembly, part, drawing etc) and send it across to people who do not have Inventor or even upload the image online. You would have to follow one of the following two options
Option A: File > Save As> Save Copy As> and then select .jpg or .png as extension and save the file.
Option B: Use “Print Screen” key on your keyboard, go to MS Paint or other image editing software, paste the copied image and then save it.
At AR-CAD, we have developed a simple addin for Autodesk Inventor which lets you take screenshot or capture the current view of Inventor and save it as a jpg / png / gif or bmp image. And the best part about this addin is that its for FREE !!!. The addin developed is pretty simple and we just wanted to help Inventor users. We have developed the addin using Visual C#. Below images show an overview of IN-Screenshot usage in Inventor 2009 and Inventor 2010 (which has a Ribbon User Interface). To know more details and download IN-Screenshot addin, check out AR-CAD website.
It presently works on Inventor 2009 and 2010 versions and should also be able work on 2011, when it would be released. We have tested it to work on both 32 and 64 bit OS of Windows XP, Windows Vista and Windows 7.
You are free to try the addin and let us know your valuable feedback.
Disclaimer: Some days ago, I had come across a blog post pointing to ADN Addin of the month being awarded to a similar Inventor addin which saves the active view as an image. I had developed IN-Screenshot atleast an year ago and have no link with the other addin.
A screenshot of IN-Motion running on Autodesk Inventor 2010 is below.
Please keep checking this blog for more updates and tutorials on IN-Motion and also Dynamic Simulation using Autodesk Inventor. If you have any query, please email to the following
Aik-Siong Koh (askoh@askoh.com) and Rajeev Lochan (rajeev@ar-cad.com)
How to minimize forms that belong to a particular application, when the parent application (In my case Autodesk Inventor) is minimized ? When you create software or addins, you would want the forms/dialogs to be minimized and not floating around when parent application is minimized.
For that we need to deal with hWnd of parent application. “hWnd” stands for Window Handle, which is the API call to the window(parent application). Since we come across this too often in Inventor customization to make addins, I have created a Class and a couple of methods for better clarity. Before I go into details, lets see what are the different types of Forms/Dialogs you would deal while developing Windows based software.
1)Modal Forms or Dialog Box
The modal forms are used when you want the user to enter some values and unless the form/dialog is closed, he/she cannot interact with other controls in the application. All the MessageBox’s are of modal types. The image on the left is also an example of Modal forms. Here, the user has to enter/select details of Graph plots in our addin IN-Motion.
2. Modeless Form
The modeless forms are used when user can enter values into the form and also can interact with other controls in application, even when the form is not minimized. The image on the left is the Simulation playback deck in IN-Motion.
Coming back to our problem of minimizing forms with parent application, below is the code. If the user minimizes Inventor application(parent form), its child forms are also minimized.
//
//Declare and set..here m_inventorApplication is the application
//MainFrameHWND returns its handle.
//WindowsWrapperForForm is a Class, defined at the bottom
WindowsWrapperForForm m_windowsWrapperForForm = new
WindowsWrapperForForm((IntPtr)m_inventorApplication.MainFrameHWND);
//Declare and set a form .. ModalCmdDlg is our modal form
ModalCmdDlg m_modalCmdDlg = new ModalCmdDlg();
//Declare and set a form .. ModelessCmdDlg is our modeless form
ModelessCmdDlg m_modelessCmdDlg = new ModelessCmdDlg();
//Show Modal form
ShowModalForm(m_modalCmdDlg);
//Show Modeless form
ShowModelessForm(m_modelessCmdDlg);
//Methods
private void ShowModalForm(Form _modalCmdDlg)
{
_modalCmdDlg.Activate();
_modalCmdDlg.ShowInTaskbar = false;
//ShowDialog is used..for Modal forms
_modalCmdDlg.ShowDialog(m_windowsWrapperForForm);
}
private void ShowModelessForm(Form _modelessCmdDlg)
{
_modelessCmdDlg.Activate();
_modelessCmdDlg.ShowInTaskbar = false;
//Show is used..for Modeless forms
_modelessCmdDlg.Show(m_windowsWrapperForForm);
}
//Below is the code for Class WindowsWrapperForForm
//****************Class***************
class WindowsWrapperForForm : System.Windows.Forms.IWin32Window
{
private IntPtr m_hwnd;
public WindowsWrapperForForm(IntPtr handle)
{
m_hwnd = handle;
}
#region IWin32Window Members
public IntPtr Handle
{
get { return m_hwnd; }
}
#endregion
}
//****************EndClass*******************
I was searching for an opensource(hence free) Graph plotting library in C# (or VB.NET), so that it could be used in our IN-Motion addin for Autodesk Inventor. After some googling, I found 2 suitable open source libraries namely ZedGraph and NPlot. When both websites(read wiki) were compared, I found ZedGraph recently updated and also had great documentation to take off immediately. I readily downloaded the latest version of ZedGraph dll from its SourceForge project and followed the instructions on ZedGraph wiki.
Within no time, I was ready with ZedGraphTest example, whose screenshot is above. It is so simple that, without even exploring, I could accomplish basic graph plotting. Some of the plus points I see in ZedGraph are:
Not much tweaking of source-code is required for basic tasks.
All the plot elements (line, curve, panel, axes, plot-markers etc) can be set different colors. Even gradients can be set to have crazy as well as good looking Graphs
Different types of graphs (line,bar,pie etc) are possible with ease.
Using left click on the plot panel, the graph can be zoomed
Middle button can be used to pan the plot
Upon right click over the plot, a context menu appears which, out of the box has a lot of useful features such as saving the image, toggle the on-hover highligthing etc
The code for my ZedGraphTest is below. I have changed only CreateGraph() method, and the remaining code is same as in the example.
private void CreateGraph(ZedGraphControl zgc)
{
GraphPane myPane = zgc.GraphPane;
// Set the titles and axis labels
myPane.Title.Text = "ZedGraph Test";
myPane.XAxis.Title.Text = "theta (angle)";
myPane.YAxis.Title.Text = "Sin (theta)";
// Make up some data points from the Sine function
PointPairList _list1 = new PointPairList();
for (double x = 0; x <= 360; x += 10)
{
double y = Math.Sin(x * Math.PI / 180.0);
_list1.Add(x, y);
}
// Generate a blue curve with Plus symbols,
LineItem _myCurve1 =
myPane.AddCurve("Sin (theta)", _list1, Color.Blue,SymbolType.Plus);
// Fill the pane background with a color gradient
myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);
//Make the MajorGrids of Axes visible
myPane.XAxis.MajorGrid.IsVisible = true;
myPane.YAxis.MajorGrid.IsVisible = true;
// Calculate the Axis Scale Ranges
zgc.AxisChange();
}
So far, this library has been a boon to me as I dont have to reinvent the wheel again. Thanks a ton to ZedGraph guys
AUGI is the Autodesk User Group International, officially recognized by Autodesk as representing the Autodesk user community. AUGI has two prime directives. The first is to assist its members by presenting programs and information that will enhance their use of Autodesk products. The second is to deliver the voice of the user community to Autodesk, thus assisting Autodesk in product development and giving users a say in the process.
AUGI is a free community with a lot of benefits for its members. You can join it by clicking on the banner to the left.
AUGI World : It is the official publication of AUGI, is a bimonthly magazine designed to help readers improve their use of Autodesk products and learn new techniques. Every issue is packed with product tips & tricks and other technical fare, CAD management issues, and education trends.
AUGI HotNews: It is the monthly newsletter written for AUGI members, brings them up to date on the latest from AUGI, Autodesk, and the Autodesk community. With feature articles, product tips, special offers and announcements, HotNews keeps AUGI members in the loop.
Like any other active community, AUGI has spread across the world in the form of Country Chapters and Local Chapters (City wise). I belong to AUGI India Chapter and Bangalore Local Chapter. Recently, I got an opportunity to write an article about Inventor Customization in AUGI India HotNews September 2008 edition. I have tried to keep it simple and logical that even a person without much or any programming experience can understand it. You can find the article at AUGI India HotNews page, go to September 2008 edition and my article is listed as Autodesk Inventor API and Customization. The article is titled “Autodesk Inventor API and Customization for Dummies Part - I “. As evident from the title, I intend to write more articles for AUGI which would continue from where I have stopped.
Summary: How to Add extra buttons to already existing Addin Command Bar.
This is in continuation of my earlier posts on Developing Inventor Addins using C# Part1, Part2, Part3 and Part4. In our last screencast, I had explained how to replicate assembly tree view inside our addin command dialog. We go a step further and interact with the opened Assembly document / file.
In this ScreenCast, we mainly deal with How to add another button to our existing addin command bar. By clicking on that button, a form would show up. We use SelectSet method of Inventor to capture user Selections. In screencasts to follow, we would try to explore how InteractionEvents can be used in place of SelectSet.
Upon selecting an ocurrence (Part/ Sub-assembly), the label in our Form is changed to its Display Name. Its not a big deal though, but atleast we are heading in the right direction.
Would love to hear any feedback in the form of comments.
This is in continuation of my earlier posts on Developing Addins for Autodesk Inventor using C# Part1, Part2 and Part3. In this screencast, I have introduced a TreeView component in our Custom Form, which gets displayed upon clicking on our Addin Button. I have also introduced concept of ImageList briefly and how it was coupled together with our TreeView.
We also added a new set of methods/ functions in AssemblyTreeCmdDlg.cs file. The major part of the code has been taken from AssemblyTree Apprentice Server example, that gets shipped with Inventor SDK.
Upon clicking on Submit button (on our Form), Inventor quickly produces a TreeView with all the Parts, Sub-Assemblies in the active assembly file, and also shows the Constraints that each of these parts / sub-assemblies have.
This post is in continuation of my earlier posts on Developing Addins for Inventor using C# part1 and part2. In this screencast / video tutorial, we go a step forward and show a Form / Command Dialog when our Custom Button is clicked in Inventor. The form created is very much basic. Ideally the form should minimize along with Inventor if Inventor is minimized. That part is not taken care of in this screencast. It would be done in coming tutorials.
When our Custom Button is clicked (OnExecute), a form is displayed with a label and a Submit Button. Upon clicking Submit Button, the file name of the active document (opened file) is retrieved from Inventor Application object and updated in the Form.
If you have followed my earlier screen casts on Developing Inventor Addin using C# (Visual Studio) here and here, I had not touched anything on How to debug an Addin using Visual Studio. When you build / register an Addin, a DLL (Dynamic Link Library) file is created which Inventor identifies as an Addin. To be able to debug an Addin, you have to step into Inventor Process. This can be done as follows.
If you are using a free version of Microsoft Visual Basic (Express Edition), it does not have a debugging option for COM objects out of the box. This can be done with the following work around / trick
Create a file with a name <yourAddinDllName>.csproj.user (In my case, it is AR-CADInventorAddIn4.csproj.user
Put the following content into this file (The only thing that could probably change is the location of your Inventor.exe file)
Close the solution and open it again. By doing this, the .csproj.user file is associated with the project.
Insert a “Break Point” in your code and Start Debugging by hitting F5 key.
Now Inventor gets started and you are halted at the break point. Use Step Through and Step Into to inspect different objects, by hovering the mouse over the objects.
When you are done with Debugging, your addin would load up and hence Inventor is loaded completely. You can also insert break points when you click on a Custom Button , your addin has created when the Inventor is loaded completely.
If you happen to have a Visual Studio Professional version, there is no need to create the .csproj.user file, you can follow these instructions to get the debugger working.
Right Click on your addin project. Go to its properties.
Go to Debug Tab listed in the left side of this dialog.
Set Configuration = Debug , Platform = Any CPU
Set Start External Program to the location pointing to Inventor.exe
Close the properties Dialog box
In the Solutions Explorer, click on an icon “Show All Files”
Carry on with your debugging session as explained above and also in the screencast
I hope things are pretty much clear, if there are any queries, I would love to hear them in the form of comments.
This video tutorial is in continuation of my earlier post on Developing Autodesk Inventor Addin using C# - part 1. In this session, we go a step further and create Command Button(s), that is added into a Custom Command Bar, which in turn gets added into Panel Bar of Assembly Files.
We start with a project that gets formed when we use Inventor Addins Template for C# language. We then add a couple of references and use most of the code from SimpleAddin that gets shipped along with Inventor in its SDK kit. We use the Button class from SimpleAddin as it is, and then append code to StandardAddInServer.cs file as explained in the video.
Some of the main points discussed in the video are as follows:
How to deal with User Interface Event
How to deal with Event Handler for Command Bars and Environments on Reset
How to use ‘try & catch’ loop to handle errors effectively
How to extend Button base class. Each ButtonCommand (AssemblyTreeButton) will have a Class which implements Button class
How to load Image icons (.ico) for User Interface items
How to create Buttons (CommandButtons)
How to create Command Category
How to add Button to Command Category
How to create a custom command bar (toolbar), only the first time the addin loads up
How to add a custom command bar to an available Environment (again only first time)
How to Restore CommandBars and Environments and clean up the custom CommandBars and Environment changes done by activate method
How to run a command when a button is clicked
How to Build a Solution from Visual Studio 2005
How to register and unregister an Addin using RegAsm.exe (easier way)
How to check whether you addin has been loaded in the Inventor when it is started
I hope a lot of basics of a Command Button are covered in this video tutorial. In the coming ones, I would try to work on “Debugging an Addin from Visual Studio” and more complex addins which actually do something other than just showing some messages.
Please comment below if there is anything that is not clear. To view high resolution Videos of the above screencasts, check them out at AR-CAD at part2a, part2b, part2c.
Update: Looks like the install.bat and uninstall.bat files content are not very clear in the video, here are they in text
I am a Mechanical Engineer turned CAD Enthusiast. Recently I have co-developed and launched IN-Motion, a Motion and Dynamic Simualtion Addin for Autodesk Inventor.