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: 

Insert Sketched Symbol at Center of Part via C#

2 REPLIES 2
Reply
Message 1 of 3
bennywise578
1164 Views, 2 Replies

Insert Sketched Symbol at Center of Part via C#

Hi,

 

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);
points.Add(oCoord3);

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

i++;
}

 

***************************************************************************************************************************************

 

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.

2 REPLIES 2
Message 2 of 3
bennywise578
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!

Message 3 of 3
mat_hijs
in reply to: bennywise578

Did you ever find a solution to this? I'm trying to do the same thing and I'm running into the same issues.

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

Post to forums