0% found this document useful (0 votes)
19 views2 pages

Custom Part Code in C#

C# code on how to model custom part

Uploaded by

jevaky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Custom Part Code in C#

C# code on how to model custom part

Uploaded by

jevaky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

using System;

using [Link];

using [Link];
using [Link];
using [Link].Geometry3d;

public class StructuresData3


{
[StructuresField("P1")]
public double Parameter1;
[StructuresField("P2")]
public string Parameter2;
}

[Plugin("CustomBeam")] // The name of the connection in the catalog


[PluginUserInterface(UserInterfaceDefinitions.Plugin3)]
public class CustomBeam: CustomPartBase
{
private readonly StructuresData3 data;

public CustomBeam(StructuresData3 data)


{
[Link] = data;
}

static Beam CreateBeam(Point point1, Point point2, string profile)


{
Beam myBeam = new Beam(point1, point2);
[Link] = profile;
[Link] = "PAINT";
[Link] = [Link];
[Link] = [Link];
[Link]();
return myBeam;
}

static void CreateFitting(double thickness, Beam myPart)


{
Fitting myFitting = new Fitting();
[Link] = new Point(thickness, 0, 0);
[Link] = new Vector(0, 1000, 0);
[Link] = new Vector(0, 0, 1000);
[Link] = myPart;

[Link]();
}

public override bool Run()


{
try
{
// The default values
if(IsDefaultValue(data.Parameter1))
data.Parameter1 = 300.0;
if (IsDefaultValue(data.Parameter2))
data.Parameter2 = "PL10*300";

// Get input points


Point point1 = new Point([Link][0]);
Point point2 = new Point([Link][1]);
if (data.Parameter1 > 0)
{
point1.Y -= data.Parameter1 / 2;
point2.Y += data.Parameter1 / 2;
}

Beam newBeam = CreateBeam(point1, point2, data.Parameter2);

double thickness = 0.0;


[Link]("[Link]", ref thickness);
CreateFitting(thickness, newBeam);
}
catch(Exception e)
{
[Link]([Link]());
}

return true;
}

public class UserInterfaceDefinitions


{
public const string Plugin3 = @"" +
@"page(""TeklaStructures"","""")" + "\n" +
"{\n" +
" joint(1, BeamConnection)\n" +
" {\n" +
@" tab_page(""Beam test"", ""Parameters"", 1)" + "\n" +
" {\n" +
@" parameter(""Plate Length"", ""P1"", distance, number, 1)" +
"\n" +
@" parameter(""Profile"", ""P2"", profile, text, 2)" + "\n" +
" }\n" +
" }\n" +
"}\n";
}
}

You might also like