AddFiniteRevolvedProtrusion

 

Hello,

after delphi problems, i'am trying in C#.

I can draw a profil, but when i try to revolve it, i can't make the Refaxes.

I made 2 methods, but no one works.

The better for me is if the revolve axis is one of the coordinate axes.

 Thanks for any help.

 

First version:

 

SolidEdgeFrameworkSupport.Line2d line = null;

SolidEdgePart.RefAxis axis = null;

line = profile.Lines2d.AddBy2Points(0, 0, 0, 1);

axis = profile.SetAxisOfRevolution(line);

 

The second version:

SolidEdgePart.RefAxes axes = null;

SolidEdgePart.RefAxis axis = null;

axes = part.RefAxes;

axis = axes.Item(1);

 

The whole program:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Reflection;

using System.Runtime.InteropServices;

using SolidEdgeConstants;

namespace WindowsFormsApplication1

{

public partial class Form1 : Form

{

SolidEdgeFramework.Application application = null;

SolidEdgeFramework.Documents documents = null;

SolidEdgePart.PartDocument part = null;

SolidEdgePart.ProfileSets profilesets = null;

SolidEdgePart.ProfileSet profileset = null;

SolidEdgePart.Profiles profiles = null;

SolidEdgePart.Profile profile = null;

SolidEdgePart.RefPlanes refplanes = null;

SolidEdgeFrameworkSupport.Relations2d relations2d = null;

SolidEdgeFrameworkSupport.Relation2d relation2d = null;

SolidEdgeFrameworkSupport.Lines2d lines2d = null;

SolidEdgeFrameworkSupport.Line2d line2d = null;

SolidEdgePart.Models models = null;

SolidEdgePart.Model model = null;

SolidEdgePart.RefAxes axes = null;

SolidEdgePart.RefAxis axis = null;

System.Array aprofiles = null;

static double[] X = new double[5];

static double[] Y = new double[5];

 

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

koordinatak();

try

{

application = (SolidEdgeFramework.Application)

Marshal.GetActiveObject("Solidedge.Application");

documents = application.Documents;

part = (SolidEdgePart.PartDocument)

documents.Add("Solidedge.PartDocument",Missing.Value);

profilesets = part.ProfileSets;

profileset = profilesets.Add();

profiles = profileset.Profiles;

refplanes = part.RefPlanes;

profile = profiles.Add(refplanes.Item(3));

lines2d = profile.Lines2d;

for (int i=0;i

{

lines2d.AddBy2Points(X,Y,X[i+1],Y[i+1]);

 

}

lines2d.AddBy2Points(X[4], Y[4], X[0], Y[0]);

relations2d = (SolidEdgeFrameworkSupport.Relations2d)

profile.Relations2d;

for (int i=1;i

{

relation2d = relations2d.AddKeypoint(lines2d.Item(i),(int)KeypointIndexConstants.igLineEnd,lines2d.Item(i+1),(int)KeypointIndexConstants.igLineStart,true);

}

relation2d = relations2d.AddKeypoint(lines2d.Item(5),(int)KeypointIndexConstants.igLineEnd,lines2d.Item(1),(int)KeypointIndexConstants.igLineStart,true);

profile.End(SolidEdgePart.ProfileValidationType.igProfileClosed);

aprofiles = Array.CreateInstance(typeof(SolidEdgePart.Profile),1);

aprofiles.SetValue(profile, 0);

models = part.Models;

axes = part.RefAxes;

axis = axes.Item(1);

model = models.AddFiniteRevolvedProtrusion(aprofiles.Length, ref aprofiles, axis, SolidEdgePart.FeaturePropertyConstants.igRight,3*Math.PI/2, Missing.Value, Missing.Value);

}

catch (System.Exception ex)

{

Console.WriteLine(ex.Message);

}

}

private void koordinatak()

{

X[0] = 0;

Y[0] = Convert.ToDouble(OD.Text)/2000;

X[1] = Convert.ToDouble(L.Text)/1000-Convert.ToDouble(H.Text)/1000;

Y[1] = Convert.ToDouble(OD.Text)/2000;

X[2] = Convert.ToDouble(L.Text)/1000;

Y[2] = Convert.ToDouble(OD.Text)/2000-(Convert.ToDouble(H.Text)*Math.Tan(Convert.ToDouble(H.Text)*Math.PI/180))/1000;

X[3] = Convert.ToDouble(L.Text)/1000;

Y[3] = Convert.ToDouble(ID.Text)/2000;

X[4] = 0;

Y[4] = Convert.ToDouble(ID.Text) / 2000;

}

}

}

 

Posted by: Ungi Laszlo
Post date: 3/11/2009 3:16:37 AM