ClientGraphics in SketchBlockDefinitions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm writing a little c# tool, where a user can mark sketch points in PlanarSketches and SketchBlockDefinitions.
The points will be marked by attributes and actually represent the bounding box of the profile for CAM processing.
While my command is active, the location and description of the points should be visible to the user, upon end of the command this info should be invisble again.
So, when the user has selected a SketchPoint, I will write a text description of the point (f.e. Origin, MaxX, MaxY, MaxXY) next to it using ClientGraphics/TextGraphics.
This works fine, as long as the user selects Points inside a PlanarSketch, but when the user edits a SketchBlockDefinition, the TextGraphics can not be seen.
here is a small example of my code:
void createClientGfx()
{
ComponentDefinition compDef = null;
Inventor.Document doc = m_inventorApplication.ActiveDocument;
if (m_inventorApplication.ActiveDocument is PartDocument)
{
compDef = (ComponentDefinition)((PartDocument)m_inventorApplication.ActiveDocument).ComponentDefinition;
}
else if (m_inventorApplication.ActiveDocument is AssemblyDocument)
{
compDef = (ComponentDefinition)((AssemblyDocument)m_inventorApplication.ActiveDocument).ComponentDefinition;
}
try
{
m_clientGraphics = compDef.ClientGraphicsCollection[CAMP_POS_GFX];
}
catch (System.Exception) { }
if (m_clientGraphics == null)
{
m_clientGraphics = compDef.ClientGraphicsCollection.Add(CAMP_POS_GFX);
}
m_node = m_clientGraphics.AddNode(1);
}
TextGraphics addtextGfx(string strText, Point2d position)
{
TextGraphics textGfx1 = m_node.AddTextGraphics();
textGfx1.Text = strText;
textGfx1.Anchor = m_inventorApplication.TransientGeometry.CreatePoint(position.X + OFFSET, position.Y, 0.0);
textGfx1.Font = "Arial";
textGfx1.FontSize = 20;
textGfx1.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextLeft;
textGfx1.Italic = false;
textGfx1.PutTextColor(255,255,0);
//textGfx1.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextBaseline;
//Call oTextGraphics(3).SetTransformBehavior(oModelAnchorPoint, kFrontFacingAndPixelScaling)
m_inventorApplication.ActiveView.Update();
return textGfx1;
}
Any help, why the code isn't working in SketchBlockDefinitions would be appreciated.
regards
Ludger