Message 1 of 4
Inserting Custom Surface Texture Symbols Onto Drawing View

Not applicable
12-20-2010
08:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey Everyone,
I'm currently writing an addin for Inventor to insert pre-defined Surface Texture Symbols into an Inventor drawing. The idea is to allow a user to simply click a button to insert their predefined texture, then they select the point to add it at and it is automatically added. I'm using an input event to allow the user to pick their selection point, and from that I create the geometry intent / insert the symbol. The program builds fine, and even works properly when a symbol is inserted onto a sketched line, but it fails at the symbol insertion when trying to insert onto an inserted view. Can anyone help me understand why the function is failing? The source code for my insertion method is below (written in C#.NET).
void UserSelect_OnSelect(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Point ModelPosition, Point2d ViewPosition, Inventor.View View) { // Get the active document in inventor Inventor.DrawingDocument oDrawDoc = (DrawingDocument)m_inventorApplication.ActiveDocument; Sheet oSheet = oDrawDoc.ActiveSheet; // get an object collection to store the geometry intent for our symbol ObjectCollection oIntent = m_inventorApplication.TransientObjects.CreateObjectCollection(); Object UserEntity; if(JustSelectedEntities.Count != 1) { MessageBox.Show("Only one entity should be selected for symbol insertion: Using first selected entity as reference point."); } try { UserEntity = JustSelectedEntities[1]; } catch (Exception ex) { MessageBox.Show("Error: " + ex); return; } TransientGeometry oGeom = m_inventorApplication.TransientGeometry; Point2d modelPoint = oGeom.CreatePoint2d(ModelPosition.X, ModelPosition.Y); // I added a leader with essentially zero length, its only purpose is to correct the orientation of the symbol oIntent.Add(oGeom.CreatePoint2d(modelPoint.X, modelPoint.Y + 0.1)); // Add the geometry intent, using the selected entity as a point of reference GeometryIntent oGT = oSheet.CreateGeometryIntent(UserEntity, modelPoint); // oIntent.Add(Translate); oIntent.Add(oGT); SurfaceTextureSymbol oSymbol; try { // insert the symbol (command fails here when inserting into a view) oSymbol = oSheet.SurfaceTextureSymbols.Add(oIntent, SurfaceTextureTypeEnum.kMaterialRemovalRequiredSurfaceType, false, false, false, "3.2", "", "", "", "", "", 0, "", "", "", Type.Missing, Type.Missing); } catch (Exception ex) { MessageBox.Show("Error: " + ex); } // stop listening to events waiting = false; }