D.S

adndevblog.typepad.com

Manufacturing DevBlog: January 2013

Manufacturing DevBlog: January 2013 Manufacturing DevBlog The resource for software developers working with Design, Lifecycle and Simulation technologies from Autodesk. Home Subscribe Follow Useful Links Autodesk About this Blog « December 2012 | Main | February 2013 » January 2013 01/06/2013 Inventor: Creating work features in VB.NET by Vladimir Ananyev Issue Is there a VB.NET example available for creating work features? Solution Work features are objects used to create and position other features and are used when current geometry is not sufficient for constructing features. There are three types of Work features: Work points Work points are placed on faces, linear edges or on arcs and circles. They can be used to mark pattern centers, define coordinate systems, and define planes and 3d paths. Work axes Work axes can be used to mark symmetry lines, centerlines or distance between revolved features. Work planes Work planes can be used when constructing axes, sketch planes, termination planes and to sketch entities on a part face when it is not available as a sketch plane. When you use the Inventor user interface to create work features you are able to select objects "visually". For example in the case of creating a workplane tangent to the cylindrical face and parallel to another planar face, in the UI all you have to do is select the cylindrical face and then select the planar face. When doing this using the API we do not have the visual feedback and it is sometimes necessary to query for geometry information in order to determine the shape and orientation of the faces. One of the attached zip files provides a VB.NET example that uses different methods to create work features. A part named “test.ipt” (2008 format) is included in the zip file and can be used with this example. Currently the code needs to find this ipt in the c:\temp. Open this file and notice there are no user defined work features. Close the ipt and then run the project. In the Form1_Load procedure test.ipt is opened and the work features are added. This example creates a workplane tangent to a cylindrical face and parallel to a planar face. It does this using Brep to obtain the Face whose shape is cylindrical, and then query for a point on the face whose normal is parallel to the planar face. See the help file for other methods for creating work features. (Such as AddByPlaneAndTangent)   Download Test  (.ipt file) Download WorkFeaturesVB_NET   Posted at 03:25 AM in AutoCAD Mechanical , Inventor , Vladimir Ananyev | Permalink | Comments (0) | | | Inventor: Scale of a Drawing by Vladimir Ananyev Issue How to view and change the scale of an IDW? Solution DrawingView object has Scale property. You may change its value to control view scale.   In C# class cls_DrawingViewScale {   public static void DrawingViewScale()   {     try     {       Inventor.Application oApp =         (Inventor.Application)System.             Runtime.InteropServices.Marshal.               GetActiveObject("Inventor.Application");         DrawingDocument oDoc =         oApp.ActiveDocument as DrawingDocument;       DrawingView view = oDoc.ActiveSheet.DrawingViews[1];         double dScale = view.Scale;       System.Windows.Forms.MessageBox           .Show("Current scale: " + dScale.ToString());                    view.Scale = 0.5; // change the scale       System.Windows.Forms.MessageBox           .Show("New scale: " + dScale.ToString());     }     catch     {        // some error     }   } } VB .NET Sub DrawingViewScale()   Try     Dim oApp As Inventor.Application _       = CType(System.Runtime.InteropServices.Marshal _           .GetActiveObject("Inventor.Application"),  _               Inventor.Application)     Dim oDoc As DrawingDocument _       = TryCast(oApp.ActiveDocument, DrawingDocument)     Dim oView As DrawingView _       = oDoc.ActiveSheet.DrawingViews.Item(1)     MsgBox("Current scale: " & oView.Scale.ToString)       oView.Scale = 0.5 ' change the scale     MsgBox("New scale: " & oView.Scale.ToString)   Catch ex As Exception     MsgBox("ERROR")   End Try End Sub In VBA Sub DrawingViewScale()     Dim oDoc As DrawingDocument     Set oDoc = ThisApplication.ActiveDocument         Dim oView As DrawingView     Set oView = oDoc.ActiveSheet.DrawingViews.Item(1)     MsgBox oView.Scale()       oView.[Scale] = 0.5 ' change the scale     MsgBox oView.Scale() End Sub   Posted at 02:57 AM in Inventor , Vladimir Ananyev | Permalink | Comments (0) | | | Inventor: Create custom property set by Vladimir Ananyev Issue The custom properties are visible to end user through the properties dialog box. How to create some properties which are not shown in UI. Solution The Inventor API supports third party property sets which can be added and deleted. You can then add properties to those third party property sets. The sample VB .NET  code shown below adds a property set "autodesk" and adds a numeric property "empID". Complete C++ project is also attached.   VB .NET code: Sub TestPro