Inventor Customization

Inventor Customization

Active Contributor
Posts: 32
Registered: ‎10-27-2011
Message 1 of 2 (537 Views)

Insert Sketched Symbol at Center of Part via C#

537 Views, 1 Replies
02-14-2012 10:36 AM



I'm currently trying to automatically cycle through all the parts in a given assembly within a drawing and place a sketched symbol at the COG of each part using C# (Visual Studio Express 2010 with Inventor 2012). The main code snippet is as follows:


//'Sketch Symbols
SketchedSymbolDefinition symDef = oDoc.SketchedSymbolDefinitions[1];


int i = 1;

while (i <= oBOMRows.Count)
BOMRow oRow1 = oBOMRows[i];
ComponentDefinition oCompDef = oRow1.ComponentDefinitions[1];

ComponentOccurrencesEnumerator occ = oAssembDef.Occurrences.AllReferencedOccurrences[oCompDef];
foreach (ComponentOccurrence occ1 in occ)

double x1 = occ1.MassProperties.CenterOfMass.X*oScale;
double y1 = occ1.MassProperties.CenterOfMass.Y*oScale;

Point2d oCoord3 = oTransGeom.CreatePoint2d(x0+x1-oDrawView1.Width/2,y0+y1+-oDrawView1.Height/2);

Inventor.ObjectCollection points;
points = ThisApplication.TransientObjects.CreateObjectCollection(null);

//SketchedSymbol sym = oSheet.SketchedSymbols.Add(symDef, oCoord3, 0, .5);
SketchedSymbol sym = oSheet.SketchedSymbols.AddWithLeader(symDef, points, 0, .5);
sym.LeaderVisible = false;





I've tried several routes, but this is my basic approach. I feel like I am missing some GeometryIntent or something of that nature as the Sketched Symbols are showing up at the correct position but they are not associated with the given part (I've attached a screenshot of what is currently happening - the wipeouts you see should be displaying a property in them that is associated to the part). I also do not want the leader to be visible.


Any help/suggestions would be greatly appreciated. Thank you.

Active Contributor
Posts: 32
Registered: ‎10-27-2011
Message 2 of 2 (513 Views)

Re: Insert Sketched Symbol at Center of Part via C#

02-23-2012 07:26 AM in reply to: bennywise578

As of now, the sketched symbols appear at the center of mass but are not physically attached to the geometry. I've tried several methods using Geometry Intent to no avail. 


All other posts on this subject utilize a user input or selection set. I want to create geometry intent at the center of each occurence and attach a sketched symbol to said geometry. Could someone atleast point me in the right direction? Any suggestions?


I'll take this in VBA or VB as well.


I'm going crazy. Please helppppppp!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.