Solved

Excel VBA Quotation tool to open, refresh, print, and save/saveas Autodesk Inventor 2011 files

Posted on 2011-03-08
5
1,317 Views
Last Modified: 2012-05-11
We have a quotation tool that runs some file save and folder generations I would like to add a routine to convert the "Quote" to a project and link it to the Ilogic rouitines I have generated in Autodesk inventor 2011. The Ilogic is triggered by a file open / save. Phase one is to produce sales and shop drawings with the ilogic tool set then triger these tools from excel as the project folders are generated. I would like to trigger this from the excel quotation tool as a macro if possible. quote tool uses outlook to send email:

Set myOlApp = CreateObject("Outlook.Application")
Set myitem = myOlApp.CreateItem(olMailItem)

is there a similar command for Autodesk Inventor?

I am self taught as a programer and would much appreciate any help i can get on the VBA side. I am very skilled in inventor and will handel the ilogic side interenally.

Thank You

Scott
0
Comment
Question by:ctowers
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:silverkorn
ID: 35072722
Autodesk is moving from VBA to VB.NET programming language, the developer's guide for .NET can be found here:
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html

If you wish to continue with VBA within AutoCAD 2010 or 2011 products you need to install module found here:
http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12715668&linkID=9240618

Here is some sample code from the .NET Developer's Guide i previously linked:

Open an existing AutoCAD Drawing:
Imports System.IO
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
 
<CommandMethod("OpenDrawing", CommandFlags.Session)> _
Public Sub OpenDrawing()
  Dim strFileName As String = "C:\campus.dwg"
  Dim acDocMgr As DocumentCollection = Application.DocumentManager
 
  If (File.Exists(strFileName)) Then
      acDocMgr.Open(strFileName, False)
  Else
      acDocMgr.MdiActiveDocument.Editor.WriteMessage("File " & strFileName & _
                                                     " does not exist.")
  End If
End Sub

Open in new window


Save the AutoCAD Drawing:
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
 
<CommandMethod("SaveActiveDrawing")> _
Public Sub SaveActiveDrawing()
  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
  Dim strDWGName As String = acDoc.Name
 
  Dim obj As Object = Application.GetSystemVariable("DWGTITLED")
 
  '' Check to see if the drawing has been named
  If System.Convert.ToInt16(obj) = 0 Then
      '' If the drawing is using a default name (Drawing1, Drawing2, etc)
      '' then provide a new name
      strDWGName = "c:\MyDrawing.dwg"
  End If
 
  '' Save the active drawing
  acDoc.Database.SaveAs(strDWGName, True, DwgVersion.Current, _
                        acDoc.Database.SecurityParameters)
End Sub

Open in new window

0
 
LVL 1

Author Comment

by:ctowers
ID: 35076790
silverkorn,

Thank you for your response. Will the code above work with Autodesk Inventor files or is it only "Autocad" specific?

thanks
0
 
LVL 12

Accepted Solution

by:
silverkorn earned 500 total points
ID: 35082389
That sample code should work with all instances of AutoCAD since they all share the common commands of open/save/close. When you get into Inventor specific tasks is when the code will not translate back to standard AutoCAD

Here is a great webinar series about programming with AutoCAD Inventor:
http://download.autodesk.com/media/adn/DevTV_Introduction_to_Inventor_Programming/
0
 
LVL 12

Expert Comment

by:silverkorn
ID: 35082438
0
 
LVL 1

Author Closing Comment

by:ctowers
ID: 35096629
Thank you for all your help and the direction. I was on the road with my tablet and couldn't see the video but got back yesterday and spent some time on it last night. It will help alot thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now