List all planes in a part, C# |
Top Previous Next |
There are always the first three planes which can be accessed by a 1 based index. Other user work planes are added from 4 onwards:
In code you can access all the planes in a part like this:
PartDocument PartDoc; try { PartDoc = (PartDocument)m_Inventor.ActiveDocument as PartDocument; if (PartDoc == null) { MessageBox.Show("This is not a part document"); return; } } catch { MessageBox.Show("not a part doc"); return; }
PartComponentDefinition PartDef = PartDoc.ComponentDefinition; WorkPlanes WPList = PartDef.WorkPlanes;
int iPlaneNumber = 1; foreach (WorkPlane ThisPlane in WPList) { Debug.WriteLine("ThisPlane is called <" + ThisPlane.Name + "> Plane number = " + iPlaneNumber.ToString()); WorkPlane Plane1 = WPList[iPlaneNumber]; Debug.WriteLine("Plane <" + Plane1.Name + "> number = " + iPlaneNumber.ToString()); iPlaneNumber++; }
This will give you output like this:
ThisPlane is called <YZ Plane> Plane number = 1 Plane <YZ Plane> number = 1 ThisPlane is called <XZ Plane> Plane number = 2 Plane <XZ Plane> number = 2 ThisPlane is called <XY Plane> Plane number = 3 Plane <XY Plane> number = 3 ThisPlane is called <PianoSpalla> Plane number = 4 Plane <PianoSpalla> number = 4
Notice that 4th plane, the first user plane.
You could use something like this:
// These help to get at workplanes WorkPlanes[] public const int ikYZPlaneNum = 1; public const int ikXZPlaneNum = 2; public const int ikXYPlaneNum = 3;
// These help to get at workaxes WorkAxes[] public const int ikXAxisNum = 1; public const int ikYAxisNum = 2; public const int ikZAxisNum = 3;
|
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)