Skip to content

Commit

Permalink
Update ExtractLocation.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Apr 11, 2023
1 parent 031d475 commit 6bda873
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions Test/ExtractLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public void GetAllXrefBlock()
tr.Commit();
}

string filepath = @"D:/test.csv";
ExportToCsv(assignmentDatas, filepath, true, ",");
Process.Start(filepath);
// string filepath = @"D:/test.csv";
// ExportToCsv(assignmentDatas, filepath, true, ",");
// Process.Start(filepath);
}

void TestTransform()
Expand Down Expand Up @@ -147,7 +147,9 @@ public void GetInfoRecord(BlockReference blockReference, ref List<AssignmentData
{
// Get position of block reference
Point3d position = blockReference.Position;
curPt = position.TransformBy(wcs);
Matrix3d inverse = blockReference.BlockTransform.Inverse();
var total = wcs * inverse;
curPt = position.TransformBy(total);
stepPt = attRef.Position.TransformBy(wcs);
// curPt add stepPt
curPt = curPt.Add(stepPt.GetAsVector());
Expand All @@ -159,8 +161,8 @@ public void GetInfoRecord(BlockReference blockReference, ref List<AssignmentData
Y = curPt.Y.ToString(CultureInfo.InvariantCulture)
});
string textCheck = "F10A2-2-F43V-He-E43-64";
string textCheck2 = "F10A2-2-F39V-He-E39-63(PT)";
if (attRef.TextString == textCheck2)
// string textCheck2 = "F10A2-2-F39V-He-E39-63(PT)";
if (attRef.TextString == textCheck)
{
MessageBox.Show(curPt.ToString());

Expand All @@ -172,22 +174,32 @@ public void GetInfoRecord(BlockReference blockReference, ref List<AssignmentData
if (attRef.Tag == "MICAP")
{
cap = attRef.TextString;
toolPosition = attRef.Position;
Point3d position = blockReference.Position;
Matrix3d inverse = blockReference.BlockTransform.Inverse();
var total = wcs * inverse;
curPt = position.TransformBy(total);
stepPt = attRef.Position.TransformBy(wcs);
// curPt add stepPt
curPt = curPt.Add(stepPt.GetAsVector());
}

if (attRef.Tag == "LID")
{
lid = attRef.TextString;
toolPosition = attRef.Position;
cap = attRef.TextString;
Point3d position = blockReference.Position;
Matrix3d inverse = blockReference.BlockTransform.Inverse();
var total = wcs * inverse;
curPt = position.TransformBy(total);
stepPt = attRef.Position.TransformBy(wcs);
// curPt add stepPt
curPt = curPt.Add(stepPt.GetAsVector());
}
}

if (!string.IsNullOrEmpty(cap))
{
string toolId = string.Join("-", lid, cap);
// Trace.WriteLine(toolId);
// Trace.WriteLine(toolPosition.ToString());
curPt = ConvertPointWcsToUcs(toolPosition.Value);
datas.Add(new AssignmentData()
{
Name = toolId,
Expand Down

0 comments on commit 6bda873

Please sign in to comment.