Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Features SuppressFeatures

Status
Not open for further replies.

Zoes

Mechanical
Sep 30, 2011
46
GB
Hi

I have radio buttons that when checked supress or unsupress features

In vb.net it works!

Dim features1(0) As Features.Feature
Dim featureGroup1 As Features.FeatureGroup = CType(workPart.Features.FindObject("FEATURE_SET(43)"), Features.FeatureGroup)
Dim errorFeatures1() As Features.Feature
features1(0) = featureGroup1
...
workPart.Features.SuppressFeatures(features1)

However when I tranfer this code to c# it does NOT! What's wrong?

NXOpen.Features.Feature[] features1 = new NXOpen.Features.Feature[1];
NXOpen.Features.FeatureGroup featureGroup1 = (NXOpen.Features.FeatureGroup)theSession.Parts.Work.Features.FindObject("FEATURE_SET(38)");
NXOpen.Features.Feature[] errorFeatures1;
features1[0] = featureGroup1

theSession.Parts.Work.Features.SuppressFeatures(features1[0], features1);

Thank you,Zoes
 
Replies continue below

Recommended for you

Try changing the last two lines to this

Code:
features1[0] = featureGroup1;

theSession.Parts.Work.Features.SuppressFeatures(features1);

Also, you should avoid using FindObject function.
This is from the docs..

"In general, this method should not be used in handwritten code and exists to support record and playback of journals. An exception will be thrown if no object can be found with the given journal identifier."

Suresh
 
Thanks for the reply

I have tried that but still have an error for overload method.
...
public FeatureGroup featureGroup1;
public FeatureGroup featureGroup2;
public Feature features1;
public Feature features2;
public Feature errorFeatures1;
public Feature errorFeatures2;
...
public classx()
{
InitializeComponent();
NXOpen.Features.Feature[] features1 = new NXOpen.Features.Feature[1];
NXOpen.Features.FeatureGroup featureGroup1 = (NXOpen.Features.FeatureGroup)theSession.Parts.Work.Features.FindObject("FEATURE_SET(2)");
NXOpen.Features.Feature[] errorFeatures1;

NXOpen.Features.Feature[] features2 = new NXOpen.Features.Feature[1];
NXOpen.Features.FeatureGroup featureGroup2 = (NXOpen.Features.FeatureGroup)theSession.Parts.Work.Features.FindObject("FEATURE_SET(3)");
NXOpen.Features.Feature[] errorFeatures2;
}
...
private void none_CheckedChanged(object sender, EventArgs e)
{

features1[0] = featureGroup1;
theSession.Parts.Work.Features.SuppressFeatures(features1);
features2[0] = featureGroup2;
theSession.Parts.Work.Features.SuppressFeatures(features2);
}

private void radio_CheckedChanged(object sender, EventArgs e)
{
errorFeatures1 = theSession.Parts.Work.Features.UnsuppressFeatures(features1)
theSession.Parts.Work.Features.SuppressFeatures(features2)
}

Can you see where the mistake can be?
Thank you,
Zoes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top