Inventor Customization

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

Insert Sketched Symbol at Center of Part via C#

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

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.

Active Contributor
bennywise578
Posts: 32
Registered: ‎10-27-2011
Message 2 of 2 (461 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!

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