It’s been a long time since my last post and I’m hoping this post is the beginning of ending the dry spell, but I’m not making any promises . It’s been a very busy past year. Professionally, It began by transferring from the Inventor development team into the ADN group that supports developers using the the API’s of all of the various Autodesk products. As part of that transfer I was hoping to be able to spend more time with you and others that are using the API’s to make the Autodesk products better. Soon after this transition I was loaned back to the development group but this time I’m working with the Fusion development team to help with the design of the Fusion API.
Earlier this week a new version of Fusion 360 was released and it contains a preview of the API (Application Programming Interface) we’ve been working on. It’s rare that any off-the-shelf product will do everything you need it to do in the way you would like it to. This applies to Fusion too but now by writing scripts that use the new API, you can drive Fusion to automate repetitive tasks and create new capabilities.
This release of the API is a preview so there’s still a lot that we need to do but there is also quite a bit of functionality as you can see demonstrated in the picture above. If you have Fusion installed you have access to the functionality and can try running some of the samples and look at the documentation. The API documentation is available on the web along with all of the Fusion product help, as shown below.
The Fusion 360 API User’s Manual contains some overview documents to help get you started and there are some sample programs that are part of help and also some that are delivered with Fusion. The available programs, or scripts, are accessible through the Scripts Manager, as shown below.
We would very much like to hear your comments about the API, both about what’s in this preview release and what functionality you would like to see exposed next in upcoming releases.
Have you been wondering what Fusion 360 is all about? If you are in the Bay area, now is your chance to find out. The San Francisco Fusion 360 Meetup group is holding a Meetup the evening of Thursday, August 21st at Pier 9. Lots of networking, food, beverages, lively presentations and awesome demos from Autodesk and Fusion 360 community members.
Sign up here to stay in touch or attend the event. Oh, did I mention? Free beer!
The new 3D viewer is really cool. To try it out you use your Autodesk 360 account. You can upload your files (by folder if you want) and then view them using the new viewing web service. (it does a lot more than just viewing) The viewer is in Tech Preview but it is working very well. Also you will need a WebGL-enabled browser. You can use this site to test.
Here is a model of a front loader using the viewer. (Model courtesy of Engineering Center) This model is being served up by a demo service that takes care authentication. For more information, please refer to Kean's original post
Aside from the standard zoom, pan and orbit, in this model, you can press the structure button to browse down through the model's assembly structure or component hierarchy. You can use this to isolate specific components in your model, hiding everything else.
Double click an individual building component to highlight it, list its identity and other properties.
After hitting reset , now try the explode button and then manipulate the slider that appears at the top of the window to move the various model components outwards from the center to form an exploded view.
Please note that these super-simple single-line embedded viewers do not immediately support all the possible functionality. It is – or will be soon, we hope – really easy to implement that in a slightly more full-fledged context, though.
Aside from the need to support a huge array of formats, the viewer is really good at streaming large models – displaying them at appropriate levels of detail – and allowing you to get in and work with the structure of these models.
Inventor 2015 will soon be shipping. Most of the API enhancements are keeping up with the new Inventor 2015 functionality and some of the enhancements are catching up to things that have been available from the Inventor user interface in previous releases.
Enhancements in the API for Parts
The SweepFeature has a new option for twist angle and now instead of having a method call that takes all the arguments to create a sweep you create a definition object and set all the properties on that object and provide definition as input to create the sweep. In the UI when you click the sweep command the dialog comes up it gathers all of the inputs needed to create the sweep but the sweep is not actually created until you click ok. You can consider the definition object as similar to the dialog.
Previous to Inventor 2015 you could create a mid plane between two parallel planes. Inventor now supports the creation of a plane between any two planes and they do not have to be parallel. An example of this is bisecting two perpendicular planes. A new point argument that defines which quadrant to use needs to be provided because if the planes are not parallel there are two possible solutions.
Work plane created using WorkPlanes.AddByTwoPlanes()
In the UI the direct edit feature lets you push and pull features. The API has read support and allows you to find information such as which operations were defined.
Another enhancement in the user interface is T-Spline capabilities. In the product it is referred to as a Freeform. The 2015 API has minimal support for this but should change in the future. In this release you can find the FreeformFeature and do basic feature operations such as getting its name, suppressing it or reordering it in the tree.
Inventor 2015 has changes to sketching that makes it more intuitive to use. The API has been updated because there are quite a few new settings.
These settings are exposed through the API.
Enhancements in the API for Sheet metal
Punch – cut across bend
Now when you do a punch you have an option to have the punch cut across a bend.
Punch on the right used cut across bend
You can think of it as unfolding the part and doing the punch and then folding it back. (the edges are normal to the flat)
Punch – cut normal to the flat pattern
In this case the edges will be perpendicular to the flat. Instead of being perpendicular to the sketch. This will make it easier to fabricate the part.
Cut on the left is normal to the flat
How it looks in the flat pattern.
Flat pattern orientation
You now have more control over the flat pattern orientation. In the UI there is a new dialog where you can pre define multiple orientations and switch between those and the API provides full access.
Enhancements in API for Assemblies
There are new methods to import and export the BOM customization file. The API has some support for the BOM but it does not support defining the BOM structure. A solution is to interactively create the BOM structure that you want and export it. Using the API you can import that to have a custom BOM structure.
The assembly symmetry constraint has a new option to control the orientation and the API was enhanced to provide that capability.
Enhancements in API for Drawings
Hole table title
In this release you have control over hole table title.
Foreshortened drawing dimensions are linear, angular, and arc length dimensions.
The FileManager object now has a method ReferencedDocumentCount that will allow you to get the number of referenced documents. The WillOpenExpressDefault method will allow you to find out whether the input assembly will open in Express mode by default. To use these methods you just pass in a file name and it returns the information.
A lot of people have been experimenting with the Leap Motion device which allows you to track hand movements and convert that into some type of CAD interaction. I did some experimenting in Inventor and Kean Walmsley posted about some of his work with AutoCAD. As cool as the Leap Motion device is, it sometimes leaves you wanting for a bit more.
A nice addition is 3D video so instead of trying to understand how your 3D hand motions translate into the flat screen, the CAD model pops out of the screen making it much more intuitive to interact with.
Another addition to this mix of technology is a new prototype touch feedback glove. This is different than force feedback in that it doesn't push back but instead just "touches" you. Their are a few hundred small magnetically activated pistons at each fingertip. They can be programmed to push against your finger at various depths. When using the glove you get the feedback that you're touching something and with the fine granularity of the pistons can even feel the shape of the object.
By combining these three technologies you get a very immersive experience when interacting with your CAD model. The video below shows an early prototype of "grabbing" a bolt in Inventor and inserting it into a hole.
A future improvement is to add voice recognition. This can especially be useful to activate commands and provide input while one hand is occupied with the touch feedback glove.
What’s DevDays you ask? It’s an event that the Autodesk Developer Network (ADN)team puts together every year to introduce the upcoming product releases and their new API functionality. It consists of presentations, demonstrations, and a chance to ask the experts your questions. In a few cities there are also DevLab’s scheduled which is a full day reserved for you to get 1-on-1 help with your questions about Autodesk’s various API’s.
In the past this event has always been an exclusive event for ADN members but this year it’s being opened up for others to attend. Below are the locations and dates for the sessions. I’ll be attending the conference and the DevLab in Las Vegas in December and would like to meet and see what you’ve been doing with Inventor’s API and help with programming questions you might have.
Asia and Australia November 7, 2013 – Developer Day, Beijing, China November 8, 2013 – DevLab, Beijing, China November 11, 2013 – Developer Day, Shanghai, China November 12, 2013 – DevLab, Shanghai, China November 13, 2013 – Developer Day, Seoul, South Korea November 15, 2013 – Developer Day, Tokyo, Japan November 18, 2013 – Developer Day, Melbourne, Australia November 19, 2013 – Developer Day, Osaka, Japan November 20, 2013 – Developer Day, Singapore, Singapore November 22, 2013 – Developer Day, Bangalore, India
North America December 2, 2013 – Autodesk® Developer Network Conference, Las Vegas, USA December 3, 2013 – DevLab, Las Vegas, USA
Europe December 9, 2013 – Developer Day, Paris, France December 10, 2013 – Developer Day, Milan, Italy December 11, 2013 – Developer Day, Farnborough, United Kingdom December 12, 2013 – Developer Day, Munich, Germany December 13, 2013 – DevLab, Munich, Germany December 16, 2013 – Developer Day, Gothenburg, Sweden December 18, 2013 – Developer Day, Moscow, Russia
South America February 5, 2014 – Developer Day, São Paulo, Brazil February 12, 2014 – Developer Day, Mexico City, Mexico
You can learn more about the logistics of the conference at the registration page. Below is the information from the ADN team about the event:
Where Desktop meets the Cloud
Got great ideas for cloud and mobile apps? Want to learn where Autodesk is taking the convergence of desktop computing and cloud technology?
If you’re an innovator developing on Autodesk platform technology and have not yet attended an Autodesk Developer Network Conference join us for a deep dive as we take an in-depth look at Autodesk’s newest technologies and the next generation of products coming in 2014. The Autodesk Developer Network is holding its annual, worldwide Developer Day Conference and DevLab in cities around the world from November 2013 through February 2014.
Called Autodesk DevDays 2013, the theme for this year’s event is rEvolution – Where Desktop meets the Cloud. Come and learn about upcoming releases of several new web service APIs from Autodesk. You’ll see how these new web services extend the power of the desktop: delivering easy collaboration, limitless compute power and big data – and are platforms that can deliver the same to you and your customers. It’s an opportunity to learn about a range of “360 based” web service APIs delivering you Cloud based platforms for a number of industries - Manufacturing, AEC, Infrastructure and more. And, we will of course also cover what’s new in the next releases of our desktop products (AutoCAD®, Autodesk® Revit®, Autodesk® Inventor®, AutoCAD® Civil 3D® and so on)!
Note that material at Developer Days is forward-looking and highly confidential so ADN membership is required. Maybe you are using ADN Open and forums and would like to attend DevDays? Visit www.autodesk.com/joinadn or send an email to your local ADN representative and let’s talk. We like to hear from — and help — interested parties, innovators and companies just getting started.
I was recently asked a question about the best way to create a PDF file for every drawing in a specified directory and it’s subdirectories. My answer is to write a small Visual Basic application to do it. Visual Basic Express (which is free) is fully capable of creating an application like this.
Below is the minimal code to get all of the files within a directory and perform some type of process on each one. The first line calls the .Net GetFiles function and passes in the directory name, a search pattern, and an argument indicating that all subdirectories should also be searched. This used to be a lot of work in VBA and is now a single line with .Net. Next it iterates over the list of filenames that were found and opens each one in Inventor, calls the SaveAsPDF function, and then closes the document. The SaveAsPDF function is a function I wrote that’s not shown below but it calls the PDF translator and exports the drawing to PDF. By simply replacing the SaveAsPDF call with a call to a different function you can change this program to do any type of processing you want.
' Get all of the drawing files in the directory and subdirectories. Dim drawings() As String = System.IO.Directory.GetFiles( _ txtPath.Text, _ "*.idw", _ System.IO.SearchOption.AllDirectories)
' Iterate through the found drawings. For Each drawing As String In drawings Dim drawDoc As Inventor.DrawingDocument drawDoc = invApp.Documents.Open(drawing)
' Save the PDF. SaveAsPDF(drawDoc, _ System.IO.Path.ChangeExtension(drawing, "pdf"))
' Close the drawing. drawDoc.Close(True) Next
The above code doesn’t have any error handling or any user interface. Once you add that and a couple of bells and whistles the code grows a bit. I’ve created a full application in Visual Basic Express 2010 that has a user interface and the bells and whistles. The user interface is shown below.
You can see in the image above that some files failed to process. This is because they were created in a later version of Inventor so the version of Inventor I’m using is unable to open them. The good news is that the program handles that case correctly and reports it.
A Camera Gotcha When working with cameras associated with a graphics view you use the Camera property of the View object. Typically you’ll get the View object using the Application.ActiveView property. The behavior of the View.Camera property is that every time you call it, it returns a new camera. This behavior makes it easy to run into a very common problem when working with cameras. The code below illustrates the problem. It calls the Camera property of the View object and then calls the ViewOrientationType property of the Camera object, setting the camera position to be a standard isometric view. Once it does this it calls the camera’s Apply method. The result is that nothing happens.
' Set the camera orientation to an iso view. invApp.ActiveView.Camera.ViewOrientationType = _ IsoTopLeftViewOrientation ' Apply the camera changes to the view. invApp.ActiveView.Camera.Apply
The reason that nothing happens is that in the first line the Camera property is called and a camera is created and returned. On this camera the isometric view is specified. On the next line the Camera property is called again and another camera is created and returned. On this camera the Apply method is called, but this camera hasn’t had the view orientation set but is the same as the current view so you don’t see any visible change. The code below illustrates the correct procedure and does create the desired result. In this case the Camera property is called and the camera is returned. The orientation for that camera is defined as an isometric view and the Apply method on the same camera is called. The view then updates to reflect the new camera position.
' Get the camera from the view. Dim cam As Camera Set cam = invApp.ActiveView.Camera
' Set the camera orientation to an iso view. cam.ViewOrientationType = kIsoTopLeftViewOrientation
' Apply the camera changes to the view. cam.Apply
Applying Camera Changes Setting a property on a camera doesn’t have an immediate effect. This is because typically you’ll want to make several changes to the camera before you force the view to update. For example you might want to change both the eye and target points and then update the camera. There are two methods that cause changes to the camera take effect. They are Apply and ApplyWithoutTransition. The Apply method uses the same transition technique that inventor uses when you change to a new view orientation; it smoothly transitions from one position to another. The ApplyWithoutTransition immediately shows the new camera position without any transition. The ApplyWithoutTransition is used when you’re doing your own camera animation because you’ll be computing all of the camera positions yourself and don’t want the delay as Inventor transitions from one camera position to another.
Modifying the Camera There are three properties on the camera that control the position and orientation of the camera; the Eye, Target, and UpVector properties. There are other properties that let you control the camera’s field of view. the Perspective property lets you toggle the camera from perspective to parallel. When the camera is a perspective camera you can use the PerspectiveAngle property to control the field of view. When it’s a parallel camera you can use the GetExtents and SetExtents methods to get and set the field of view. In addition to these functions that let you directly get and set the underlying properties of a camera there are also some convenience functions that make it easier to manipulate the camera. For example, the ViewOrientationType lets you specify standard view positions, (i.e. top, front, top-left iso, etc.) and Inventor will modify the eye, target, and up vector as-needed. The Fit method takes into account the size of the model and modifies the camera so the entire model is visible. There is also a function that takes mouse input and modifies the camera to reflect the mouse movement or scrolling.
Below is some VBA code that will fly the camera around the model. To simplify the code, the target is hard coded at the origin and the up vector is the positive Z.
Public Sub RotateCamera() ' Get the active camera. Dim cam As Camera Set cam = ThisApplication.ActiveView.Camera Dim tg As TransientGeometry Set tg = ThisApplication.TransientGeometry
' Define the number of steps in the animation. Dim steps As Integer steps = 360
' Define the distance between the eye and target. Dim eyeDistance As Double eyeDistance = 15
' Calculate pi. Dim pi As Double pi = Atn(1) * 4
' Iterate the specified number of steps. Dim i As Integer For i = 1 To steps ' Calculate the x and y coordinates of the eye. Dim x As Double Dim y As Double x = eyeDistance * Cos(i / steps * (2 * pi)) y = eyeDistance * Sin(i / steps * (2 * pi))
' Set the eye using calculated x, y and a hard coded z value. cam.Eye = tg.CreatePoint(x, y, 3) ' Define the up vector as positive z. cam.UpVector = tg.CreateUnitVector(0, 0, 1)
' Apply the current camera definition to the view. cam.ApplyWithoutTransition Next End Sub
Why Use the Camera? There are several reasons you might want to use the Camera object. The first is that you have a need to control the view within Inventor. For example, you can create a custom fly-trough of an assembly or write some utilities that allow you to quickly go to certain views. The sample code above demonstrates the procedure to set the camera properties and apply it to a view. Watch for another post about how to make the camera follow a curve like what was demonstrated in the video in this earlier post.
A camera is also used to create non-standard drawing views. Using a camera you can create any view orientation you want. The following code illustrates using a camera to create a custom drawing view that is a perspective isometric view.
' Create a camera to be used to define the view orientation. Dim cam As Camera Set cam = ThisApplication.TransientObjects.CreateCamera ' Set up the camera. cam.Perspective = True cam.ViewOrientationType = kIsoTopRightViewOrientation ' Create a drawing view using the camera. Dim viewPnt As Point2d Set viewPnt = ThisApplication.TransientGeometry.CreatePoint2d(12, 12) Dim drawView As DrawingView Set drawView = drawSheet.DrawingViews.AddBaseView(doc, viewPnt, 1, _ kArbitraryViewOrientation, _ kHiddenLineRemovedDrawingViewStyle, , _ oCamera)
The Camera object can also be used to save an image as a file. You essentially capture whatever the camera is currently seeing and save that as an image file. The format of the file can be any of several popular image types, (i.e. jpg, bmp, png, gif, and tiff). This can be useful within Inventor but is particularly useful with Apprentice because Apprentice doesn’t have a visible graphics window. You can use a camera to create images for parts, assemblies, and drawings. The VB.Net code below demonstrates creating an image of a part or assembly using Apprentice. It assumes you’ve already created an instance of Apprentice and have opened the part or assembly, which are both passed into this sub, along with the filename to use for the image. The type of image created is dependent on the extension of the filename.
Private Sub CreateImage( _ Apprentice As Inventor.ApprenticeServerComponent, _ PartOrAssembly As Inventor.ApprenticeServerDocument, _ Filename As String) ' Create a new camera. Dim cam As Inventor.Camera cam = Apprentice.TransientObjects.CreateCamera ' Associate the document with the camera. cam.SceneObject = PartOrAssembly.ComponentDefinition ' Define the camera and apply the changes. cam.ViewOrientationType = _ Inventor.ViewOrientationTypeEnum.kIsoTopRightViewOrientation cam.Fit() cam.ApplyWithoutTransition() ' Save the result, defining the background color of the image. cam.SaveAsBitmap(Filename, 800, 600, _ Apprentice.TransientObjects.CreateColor(255, 255, 0), _ Apprentice.TransientObjects.CreateColor(15, 15, 15)) End Sub
The resulting image is shown below.
That’s the basics of using cameras. Watch for an upcoming post where we’ll look at a tool to better visualize the camera and how to use geometry in the model to control the camera.