Get DrawingCurves from occurrence (C#)

Get DrawingCurves from occurrence (C#)

Anonymous
Not applicable
715 Views
1 Reply
Message 1 of 2

Get DrawingCurves from occurrence (C#)

Anonymous
Not applicable

In a drawing I'm looking for components that have a certain iProperty.  If they have the iProperty, I want to turn every occurrence of that item red.

 

I can get the occurrences fine, but I'm unable to properly get the drawing curves so I can turn them red.  I'm using code from this post on ModTheMachine: http://modthemachine.typepad.com/my_weblog/2010/10/changing-drawing-curves-to-match-assembly-color.h...

 

Here's my code:

 

private static void ProcessAssemblyColor(DrawingDocument aDoc, ComponentOccurrences occurrences)
{
   foreach (ComponentOccurrence occ in occurrences)
   {
      if (occ.DefinitionDocumentType == DocumentTypeEnum.kPartDocumentObject)
      {
         TransientObjects transObjects = StandardAddInServer._mInventorApplication.TransientObjects;
         LayersEnumerator layers = aDoc.StylesManager.Layers;
         Layer colorLayer = layers[1];

         colorLayer.Color = transObjects.CreateColor(255, 0, 0); //red
         colorLayer.LineType  = LineTypeEnum.kContinuousLineType;
         colorLayer.LineWeight = 0.02;

         ObjectCollection objColl = transObjects.CreateObjectCollection();

         foreach (DrawingView drawView in aDoc.ActiveSheet.DrawingViews)
         {
            DrawingCurvesEnumerator drawingCurves = drawView.DrawingCurves[occ]; //This line throws invalid Args error
foreach (DrawingCurve drawingCurve in drawingCurves) { foreach (DrawingCurveSegment segment in drawingCurve.Segments) { objColl.Add(segment); } } aDoc.ActiveSheet.ChangeLayer(objColl, colorLayer); } } else { ProcessAssemblyColor(aDoc, (ComponentOccurrences)occ.SubOccurrences); } } }

 

 

 I've seen some things say I need to use an out object to use DrawingCurves.  If that's true, I'm not sure what to put for the first variable.

object outObject;
DrawingCurvesEnumerator drawingCurves = drawView.DrawingCurves[occ.CreateGeometryProxy(whatgoeshere?, out outObject)];

 

I'm open to other methods of turning components red in a drawing, but this is what appeared tio be the suggested method.

0 Likes
716 Views
1 Reply
Reply (1)
Message 2 of 2

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

the first argument is the native object you want to create proxy for. please refer to this post to get the idea:

 

 http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/CreateGeometryProxy-in-C/td-p/2475890

 

 

0 Likes