using System;
using System.Collections.Generic;
using System.Windows.Forms;
using TFlex.Model;
using TFlex.Model.Model2D;
using TFlex.Model.Model3D;
namespace NewMacroNamespace
{
public class Indicator
{
static Dictionary<char, byte[,]> segments = new Dictionary<char, byte[,]>();
static CoordinateNode3D node0;
static PointsLCS scs;
static Indicator()//конструктор
{
segments.Add('А', new byte[,]{{0, 1, 1, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 1, 1, 1, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1}});
segments.Add('Б', new byte[,]{{1, 1, 1, 1, 1},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 1, 1, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 1, 1, 1, 0}});
segments.Add('В', new byte[,]{{1, 1, 1, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 1, 1, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 1, 1, 1, 0}});
segments.Add('Г', new byte[,]{{1, 1, 1, 1, 1},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0}});
segments.Add('Д', new byte[,]{{0, 0, 0, 1, 1},{0, 0, 1, 0, 1},{0, 1, 0, 0, 1},{0, 1, 0, 0, 1},{0, 1, 0, 0, 1},{1, 1, 1, 1, 1},{1, 0, 0, 0, 1}});
segments.Add('Е', new byte[,]{{1, 1, 1, 1, 1},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 1, 1, 1, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 1, 1, 1, 1}});
segments.Add('Ё', new byte[,]{{0, 1, 0, 1, 0},{1, 1, 1, 1, 1},{1, 0, 0, 0, 0},{1, 1, 1, 1, 1},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 1, 1, 1, 1}});
segments.Add('Ж', new byte[,]{{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{0, 1, 1, 1, 0},{0, 0, 1, 0, 0},{0, 1, 1, 1, 0},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1}});
segments.Add('З', new byte[,]{{0, 1, 1, 1, 0},{1, 0, 0, 0, 1},{0, 0, 0, 0, 1},{0, 0, 1, 1, 0},{0, 0, 0, 0, 1},{1, 0, 0, 0, 1},{0, 1, 1, 1, 0}});
segments.Add('И', new byte[,]{{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 1, 1},{1, 0, 1, 0, 1},{1, 1, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1}});
segments.Add('Й', new byte[,]{{1, 0, 1, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 1, 1},{1, 0, 1, 0, 1},{1, 1, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1}});
segments.Add('К', new byte[,]{{1, 0, 0, 0, 1},{1, 0, 0, 1, 0},{1, 0, 1, 0, 0},{1, 1, 0, 0, 0},{1, 0, 1, 0, 0},{1, 0, 0, 1, 0},{1, 0, 0, 0, 1}});
segments.Add('Л', new byte[,]{{0, 0, 1, 1, 1},{0, 1, 0, 0, 1},{0, 1, 0, 0, 1},{0, 1, 0, 0, 1},{0, 1, 0, 0, 1},{0, 1, 0, 0, 1},{1, 1, 0, 0, 1}});
segments.Add('М', new byte[,]{{1, 0, 0, 0, 1},{1, 1, 0, 1, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1}});
segments.Add('Н', new byte[,]{{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 1, 1, 1, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1}});
segments.Add('О', new byte[,]{{0, 1, 1, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{0, 1, 1, 1, 0}});
segments.Add('П', new byte[,]{{1, 1, 1, 1, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1}});
segments.Add('Р', new byte[,]{{1, 1, 1, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 1, 1, 1, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0}});
segments.Add('С', new byte[,]{{0, 1, 1, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 1},{0, 1, 1, 1, 0}});
segments.Add('Т', new byte[,]{{1, 1, 1, 1, 1},{0, 0, 1, 0, 0},{0, 0, 1, 0, 0},{0, 0, 1, 0, 0},{0, 0, 1, 0, 0},{0, 0, 1, 0, 0},{0, 0, 1, 0, 0}});
segments.Add('У', new byte[,]{{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{0, 1, 1, 1, 1},{0, 0, 0, 0, 1},{1, 0, 0, 0, 1},{0, 1, 1, 1, 0}});
segments.Add('Ф', new byte[,]{{0, 1, 1, 1, 0},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{0, 1, 1, 1, 0},{0, 0, 1, 0, 0},{0, 0, 1, 0, 0}});
segments.Add('Х', new byte[,]{{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{0, 1, 0, 1, 0},{0, 0, 1, 0, 0},{0, 1, 0, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1}});
segments.Add('Ц', new byte[,]{{1, 0, 0, 1, 0},{1, 0, 0, 1, 0},{1, 0, 0, 1, 0},{1, 0, 0, 1, 0},{1, 0, 0, 1, 0},{1, 1, 1, 1, 0},{0, 0, 0, 0, 1}});
segments.Add('Ч', new byte[,]{{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{0, 1, 1, 1, 1},{0, 0, 0, 0, 1},{0, 0, 0, 0, 1}});
segments.Add('Ш', new byte[,]{{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 1, 1, 1, 1}});
segments.Add('Щ', new byte[,]{{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 1, 1, 1, 1},{0, 0, 0, 0, 1}});
segments.Add('Ъ', new byte[,]{{1, 1, 0, 0, 0},{0, 1, 0, 0, 0},{0, 1, 0, 0, 0},{0, 1, 1, 1, 0},{0, 1, 0, 0, 1},{0, 1, 0, 0, 1},{0, 1, 1, 1, 0}});
segments.Add('Ы', new byte[,]{{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 1, 0, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 1, 0, 0, 1}});
segments.Add('Ь', new byte[,]{{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 0, 0, 0, 0},{1, 1, 1, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{1, 1, 1, 1, 0}});
segments.Add('Э', new byte[,]{{0, 1, 1, 1, 0},{1, 0, 0, 0, 1},{0, 0, 0, 0, 1},{0, 0, 1, 1, 1},{0, 0, 0, 0, 1},{1, 0, 0, 0, 1},{0, 1, 1, 1, 0}});
segments.Add('Ю', new byte[,]{{1, 0, 0, 1, 0},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 1, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 1, 0, 1},{1, 0, 0, 1, 0}});
segments.Add('Я', new byte[,]{{0, 1, 1, 1, 1},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1},{0, 1, 1, 1, 1},{0, 0, 1, 0, 1},{0, 1, 0, 0, 1},{1, 0, 0, 0, 1}});
Document doc = TFlex.Application.ActiveDocument;
doc.BeginChanges("ЛСК");
CoordinateNode3D node0 = new CoordinateNode3D(doc); //3D Узел_1
node0.X = 0; node0.Y = 0; node0.Z = 0; node0.VisibleInScene= false;
PointsLCS scs = new PointsLCS(doc); //ЛСК_1
scs.PointToOrigin=node0.Geometry.Point; scs.VisibleInScene= false;
doc.EndChanges();
}
public static void matrix(Profile prof, char val,int m, Document doc)
{
doc.BeginChanges("копия профиля");
CoordinateNode3D node1 = new CoordinateNode3D(doc);
node1.X = 0-m*8.3*6; node1.Y = 0; node1.Z = 0; node1.VisibleInScene= false;
CoordinateNode3D node2 = new CoordinateNode3D(doc);
node2.X = -8.3-m*8.3*6; node2.Y = 0; node2.Z = 0; node2.VisibleInScene= false;
CoordinateNode3D node3 = new CoordinateNode3D(doc);
node3.X = -m*8.3*6; node3.Y = 8.3; node3.Z = 0; node3.VisibleInScene= false;
PointsLCS tcs = new PointsLCS(doc);
tcs.PointToOrigin=node1.Geometry.Point; tcs.VisibleInScene= false;
CopyOperation2 copyprof= new CopyOperation2(doc, CopyBaseOperation2.Type.Construction);
copyprof.Constructions.Add(prof);
copyprof.SourceLCS = (PointsLCS)doc.GetObjectByName("ЛСК_1");
copyprof.TargetLCS = tcs;
copyprof.VisibleInScene = false;
doc.EndChanges();
doc.BeginChanges("линейный массив");
LinearArrayOperation lao = new LinearArrayOperation(doc, ArrayOperation.Type.Operations);
lao.Operations.Add(copyprof);
lao.Direction1Point1 = node1.Geometry.Point;
lao.Direction1Point2 = node2.Geometry.Point;
lao.Direction1Number = 5;//кол-во копий
lao.Direction1StepFromVector = true;//нарпавление
lao.Direction1Step= 8;//шаг
lao.Direction1Length = 16;//длина
lao.Direction2Point1 = node1.Geometry.Point;
lao.Direction2Point2 = node3.Geometry.Point;
lao.Direction2Number = 7;//кол-во копий
lao.Direction2StepFromVector = true;//нарпавление
lao.Direction2Step= 8;//шаг
lao.Direction2Length = 16;//длина
lao.IncludeBase=true;
lao.Exclusions.Clear();
for (int j=0;j<7;j++)
for(int i=0;i<5;i++)
if (segments[val][j,i]==0) lao.Exclusions.Add(new Exclusion(lao, new Parameter(i), new Parameter(j)));
doc.EndChanges();//Закрытие блока изменений документа
}
}//end class
public class NewMacroClass
{
public static void NewMacro()
{
Document doc = TFlex.Application.ActiveDocument;
string word="ТФЛЕКС";//по дефолту
foreach(Variable v in doc.GetVariables())
{
if(v.Name == "$word")
{
word=v.TextValue;
break;
}
}
char[] val=word.ToCharArray();
if (doc == null) return;
foreach (ModelObject mo in doc.GetObjects())
{
if (mo.Name == "pixel")
{
Profile pixel1 = mo as Profile;
for(int i = 0; i < word.Length; i++)
{
Indicator.matrix(pixel1,val[i],i,doc);
}
break;
}
}
doc.Redraw();
}
}
}
|