What's new

Losing reference to part

Ron

Senior Member
In an assembly, I’m trying to use the user selected planar face on Part A to create a plane in collection of parts (Part B, Part C, and Part D).
********************************

I created a global variables named:
IADDesignPlane tempDesignPlane = null;
IADFace selectedFace = null;
********************************

In another part in the program I have this code:
if (obj is IADTargetProxy)
{
selectedProxy = (IADTargetProxy)obj;

if (selectedProxy.Target is IADFace)
{
selectedPart = (IADFace)selectedProxy.Target;
}
}

if (session.SessionType == ADObjectSubType.AD_PART)
{
justPart = (IADPartSession)session;
IADSession Newsession = (IADSession)justPart;

tempDesignPlane = justPart.DesignPlanes.CreateAtOffsetToPlane(null, selectedFace, 0, "offset plane test");

} // this is where selectedFace throws an exception. If the face that I selected is on the first part in the assembly it works for the first time through. But when it goes onto the second part, selectedFace throws an exception. If I select a face that is not on the first part in the assembly then I get the error on the first pass.
 
Top