Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inserting Custom Surface Texture Symbols Onto Drawing View

3 REPLIES 3
Reply
Message 1 of 4
johnpotocny2913
1264 Views, 3 Replies

Inserting Custom Surface Texture Symbols Onto Drawing View

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

 

 

3 REPLIES 3
Message 2 of 4

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

Message 3 of 4
MaxU77
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)
Message 4 of 4
weiser
in reply to: johnpotocny2913

Hi @johnpotocny2913,

 

did you get finished with your problem? Actually I've go to the same question.

I like to create a more efficient dialog for selecting only "our needed" surface-parameters and insert the selected symbol interactivly on the drawing by he user.

 

I've tried to use the command-manager but could get no solution ...

Mayby you have the problem solved in the meanwhile and like to shre your solution? Would be great!

 

Regards

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report