Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create a Workplane from a face using SelectSet[]

2 REPLIES 2
Reply
Message 1 of 3
bravaiser
338 Views, 2 Replies

How to create a Workplane from a face using SelectSet[]

I am making a C# Add-in, I need to create a plane from a selected face, I am using the follwing code, but I am getting stuck. Can you Help me?

 

if (((mApp.ActiveDocument != null)))
{

 

if ((mApp.ActiveDocument.DocumentType == DocumentTypeEnum.kPartDocumentObject))
{

 

PartComponentDefinition oPartCom = mApp.ActiveDocument as PartComponentDefinition;
PartDocument oDoc = mApp.ActiveDocument as PartDocument;

 

if ((oDoc.SelectSet[1]) is Face)
{


System.Windows.Forms.MessageBox.Show("You just selected a surface", "Surface Evaluator");

 

WorkPlane oPlane = oDoc.SelectSet[1] as WorkPlane; //HERE I SELECT THE WORKPLANE FROM THE FACE

//HERE I USE IT TO CREATE MY REAL WORKPLANE TO USE THE SKETCH BUT THERE IS A PROBLEM

WorkPlane oWorkPlane = oDoc.ComponentDefinition.WorkPlanes.AddByPlaneAndOffset(oPlane, 1.0);

 

 

//THIS PART SHOULD WORK AFTERWARDS

PlanarSketch oSketch = oDoc.ComponentDefinition.Sketches.Add(oWorkPlane, false);

TransientGeometry oTG = mApp.TransientGeometry;

ObjectCollection oFitPoints = mApp.TransientObjects.CreateObjectCollection();

PartComponentDefinition oCompDef = default(PartComponentDefinition);
oCompDef = oDoc.ComponentDefinition;
Camera oCamera = mApp.ActiveView.Camera;

 

....

 

}

}

 

THANK YOU GUYS!!!

2 REPLIES 2
Message 2 of 3
Mark_Wigan
in reply to: bravaiser

You could get better reponse if you post this in the inventor customisation section.

 

You mention there is a problem... when you repost, also mention what the problem is that you are encountering.

best regards,
- Mark

(Kudo or Tag if helpful - in case it also helps others)

PDSU 2020 Windows 10, 64bit.

Message 3 of 3
bravaiser
in reply to: bravaiser

The problemis that the plane oPlane is pass as null to when I used the selection (in this case a face) oDoc.SelectSet[1] as WorkPlane.

 

Thanks in advance

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report