CS_NXOpen_0009_BlockBlend
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Collections; //
Calling Array List
using NXOpen;
using NXOpen.UF;
namespace BlockBlend
{
public class EX_Block_Blend
{
private static UFSession theUfSession;
private static Session theSession;
public static void Main(string[] args)
{
theSession = Session.GetSession();
theUfSession = UFSession.GetUFSession();
//
Create Block
double[] corner_point = new double[3];
corner_point[0] = 0.0;
corner_point[1] = 0.0;
corner_point[2] = 0.0;
string[] edge_lengths = { "100.0", "200.0", "300.0" };
Tag block_feature_tag;
theUfSession.Modl.CreateBlock1(FeatureSigns.Nullsign,
corner_point, edge_lengths, out block_feature_tag);
//
Collect all the vertical edges from the Block
Tag block_tag;
theUfSession.Modl.AskFeatBody(block_feature_tag, out block_tag);
/* Get
the edges of the body. Get the count of
the edge list.
* This will be used to get the
four 'vertical' corners of the block for
* blending. Check return codes.
*/
Tag[] list1;
Tag[] list2;
int ecount;
double[] pt1 = { 0.0, 0.0, 0.0 };
double[] pt2 = { 0.0, 0.0, 0.0 };
theUfSession.Modl.AskBodyEdges(block_tag, out list1);
theUfSession.Modl.AskListCount(list1, out ecount);
ArrayList arr_list2 = new ArrayList();
for (int i = 0; i < ecount; i++)
{
Tag edge;
/* edge object */
int vcount;
/* count of vertices in edge */
/*
Get the edge (list item) and check return code.
*/
theUfSession.Modl.AskListItem(list1, i, out edge);
/*
Get the edge vertices. Check return
code. */
theUfSession.Modl.AskEdgeVerts(edge, pt1, pt2, out vcount);
if (System.Math.Abs(System.Math.Abs(pt1[2] - pt2[2]) - 300.0) < 0.001)
{
arr_list2.Add(edge);
}
}
//
Create Blend on the collected edges
int allow_smooth = 0;
int allow_cliff = 0;
int allow_notch = 0;
double vrb_tol = 0.0;
Tag blend1;
list2 = (Tag[])arr_list2.ToArray(typeof(Tag));
theUfSession.Modl.CreateBlend("20", list2,
allow_smooth,
allow_cliff, allow_notch, vrb_tol, out blend1);
}
}
}

Comments
Post a Comment