Thank you all for your help and clarification.
We managed to get it working (somehow)
A little clarification:
We are actually accessing inventor via .Net Remoting with C#.
We have an inventor Assembly with many Parts. the whole Assembly, lets say its a machine, can be configured by a Webclient.
We also have the 4 Drawings placed where we set the visibility of each Part, depending on the users configuration.
inside of some Parts are 3D-Sketches, that should also be visible/invisible if the surrounding part is visible/invisible.
But its not working this way. If i hide one part, the 3D-Sketches inside it are still visible.
so i used your code to access the 3D-Sketches directly, but again these dont react to visibility changes, so we have do DELETE the sketches by code. (And undo the deletion it after a DXF-export)
Next problem was to know the name of the Parent-Part in which the 3D-Sketches resides.
the only quick way we could manage this is with the FullFileName wich has a 3digit number in it that we can read.
I know, its a bit error-prone, but we needed a quick solution and it works (for now 😉 )
Here is part of my code:
Console.WriteLine("Searching for 3D-Sketches");
// 3D-Sketches
foreach (Document oRefDoc in oAssyDoc.AllReferencedDocuments)
{
Console.Write(".");
if (oRefDoc.DocumentType == DocumentTypeEnum.kPartDocumentObject)
{
PartDocument oPDoc = (PartDocument)oRefDoc;
if (oPDoc.ComponentDefinition.Sketches3D.Count > 0)
{
String filename = oPDoc.FullFileName;
bool visible = false;
int pos = filename.IndexOf("Parts\\");
if (pos > 0)
{
string clustername = filename.Substring(pos + "Parts\\".Length, 3);
for (int layerNr = 0; layerNr < layersToShow.Length; layerNr++)
{
if (layersToShow[layerNr].ToString("D3").Equals(clustername))
{
visible = true;
break;
}
}
}
foreach (Sketch3D oSketch3D in oPDoc.ComponentDefinition.Sketches3D)
{
for (int i = 1; i <= ActiveSheet.DrawingViews.Count; i++)
{
DrawingView dView = ActiveSheet.DrawingViews[i];
try
{
dView.SetVisibility(oSketch3D, visible);
oSketch3D.Visible = visible;
if (!visible)
{
oSketch3D.Delete();
}
}
catch (Exception e) { }
}
}
}
}
}