Inventor Customization

Reply
Member
johnpotocny2913
Posts: 3
Registered: ‎11-24-2010
Message 1 of 3 (708 Views)

Inserting Custom Surface Texture Symbols Onto Drawing View

708 Views, 2 Replies
12-20-2010 08:58 AM

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;
        }

 

 

Member
johnpotocny2913
Posts: 3
Registered: ‎11-24-2010
Message 2 of 3 (684 Views)

Re: Inserting Custom Surface Texture Symbols Onto Drawing View

12-21-2010 07:38 AM in reply to: johnpotocny2913

Hi Everyone,

 

I've been going through my code trying to figure out what the source of the problem is, and my conclusion is that the Geometry Intent that I create is breaking a rule within the method (the arguments are all valid, hence the program building correctly). Could anybody perhaps give me some direction on the proper creation/use of Geometry Intents? I would greatly appreciate it!

 

Thanks in Advance,

John Potocny

Distinguished Contributor
MaxU77
Posts: 204
Registered: ‎04-25-2008
Message 3 of 3 (609 Views)

Re: Inserting Custom Surface Texture Symbols Onto Drawing View

01-17-2011 07:48 AM in reply to: johnpotocny2913

Sorry. I can't help you with your coding. But why users can't just copy that predefined (placed first) symbol and then just press Ctrl+V as many times as necessary? That works for me fine.

 

BTW, Don't you know how to create custom button (into my custom panel) which would Insert particular Text Symbol?

MaxU77,
AI2011 Certified Associate
(Soft: PDSU2012, VP2012&VP2013)

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube