Inventor General Discussion

Reply
Contributor
bravaiser
Posts: 25
Registered: ‎08-16-2012
Message 1 of 3 (166 Views)

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

166 Views, 2 Replies
11-08-2012 02:13 PM

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!!!

*Expert Elite*
Mark_Wigan
Posts: 437
Registered: ‎03-07-2006
Message 2 of 3 (130 Views)

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

11-12-2012 05:23 AM 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

PDSU 2014 Windows 7, 64bit. (please consider Kudos or Tag as Solved if your issue is sorted)

Contributor
bravaiser
Posts: 25
Registered: ‎08-16-2012
Message 3 of 3 (126 Views)

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

11-12-2012 05:30 AM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube