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:
SketchedSymbolDefinition symDef = oDoc.SketchedSymbolDefinitions;
int i = 1;
while (i <= oBOMRows.Count)
BOMRow oRow1 = oBOMRows[i];
ComponentDefinition oCompDef = oRow1.ComponentDefinitions;
ComponentOccurrencesEnumerator occ = oAssembDef.Occurrences.AllReferencedOccurrences[oC
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,
points = ThisApplication.TransientObjects.CreateObjectColle
//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.
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!
Access a broad range of knowledge to help get the most out of your products and services.