JKLINE
-
Posts
166 -
Joined
-
Last visited
Content Type
Profiles
Forums
Downloads
Store
eMastercam Wiki
Blogs
Gallery
Events
Posts posted by JKLINE
-
-
I set the ChainManager.ChainTolerance = 0.050;
No change in result
-
-
I like this idea.
Running this offsets all but 4 chains.
if (chain.Direction == ChainDirectionType.Clockwise) { var lowerChainLarge = chain.OffsetChain2D(OffsetSideType.Right, .0225, OffsetRollCornerType.None, .5, false, .0001, false); }
Running this offsets the other 4 chains, but 2 go one direction and the other 2 go another
if (chain.Direction == ChainDirectionType.CounterClockwise) { var lowerChainLarge = chain.OffsetChain2D(OffsetSideType.Left, .0225, OffsetRollCornerType.None, .5, false, .0001, false); }
-
I am setting all the chain.Direction = ChainDirectionType.Clockwise;
It's working 14 times out of the 16 chains.
-
1 minute ago, x4g said:
Your tolernace is too big
Unfortunately, changing the tolerance did not change which direction the chain was offset
-
Broken down and still found fault.
void offsetCutchain80(){ var selectedCutChain = ChainManager.ChainAll(80); foreach (var chain in selectedCutChain){ chain.Direction = ChainDirectionType.Clockwise; var lowerChainLarge = chain.OffsetChain2D(OffsetSideType.Right, .0225, OffsetRollCornerType.None, .5, false, .005, false); GraphicsManager.ClearColors(new GroupSelectionMask(true)); } } offsetCutchain80();
-
On 12/5/2022 at 10:48 AM, Roger Martin from CNC Software said:
3> Why the templist9 and templist10 that contain the geometry entity IDs?
Seems it may be an unnecessary complication.I completely agree. I just couldn't figure out the syntax.
var chainData = chainDetails.GetData(chain); var chainEntityList = chainData.ChainEntities; foreach (var t in chainEntityList){ var firstEntity = t.Key; var secondEntity = ++t.Key;
-
Ahhh, thank you. 2023.
-
I'm looking for 'Mastercam.GeometryUtility.Types.FilletChainsParams' but VisualStudio is not finding it.
It finds the other 2 classes "BreakManyPiecesParams" and "OffsetChainParameters"
'FilletStyle' and 'ReFilletOption' also seems to be missing
Am I looking in the wrong spot?
-
Roger,
I left it in the last package I've sent to SDK. 1 problem being the moving geometry (level 80 moves to level 502) and the other being this issue.
I have also chained (manually selected) less chains and the problem moves. Making it VERY difficult for me to narrow down.
Starting with level 80, it creates level 500 which should match level 200 and it creates level 501 which should match level 300.
I've started thinking that Mastercam is thinking about ALL the geometry at once, as you said "inside the original chain". But if a chain is 'inside' another chain then it could offset to the un-intended side.
-
Correction
var chainDirection = ChainDirectionType.CounterClockwise;// Going to be used to make sure all chains go the same direction ChainManager.StartChainAtLongest(selectedChains); foreach (var chain in selectedChains) { chain.Direction = chainDirection; var chainData = chainDetails.GetData(chain); var firstEntity = chainData.FirstEntity.GetEntityID(); var lastEntity = chainData.LastEntity.GetEntityID(); var firstIsFlipped = chainData.FirstEntityIsFlipped; var lastIsFlipped = chainData.LastEntityIsFlipped; if (firstIsFlipped == false) { var entity = Mastercam.Database.Geometry.RetrieveEntity(firstEntity); if (entity is LineGeometry line) { Point3D lineStartPoint = (line.Data.Point1); Point3D lineEndPoint = (line.Data.Point2); var lineLength = VectorManager.Distance(lineStartPoint, lineEndPoint); var scale = ((lineLength - 0.010) / lineLength); entity.Scale(lineEndPoint, scale); entity.Commit(); } if (entity is ArcGeometry arc) { var arcStartPoint = (arc.Data.StartAngleDegrees); var arcEndPoint = (arc.Data.EndAngleDegrees); var arcRad = arc.Data.Radius; var arcLength = ((VectorManager.DegreesToRadians(arcStartPoint - arcEndPoint)) * arcRad); var newArcLength = (arcLength - 0.010); var circumference = 2 * Math.PI * arcRad; var arcMeasure = ((newArcLength / circumference) * 360); arc.Data.StartAngleDegrees = (arcEndPoint + arcMeasure); entity.Color = 9; entity.Commit(); } }
-
If someone needs it in the future ::
foreach (var chain in selectedChains){ chain.Direction = chainDirection; var chainData = chainDetails.GetData(chain); var firstEntity = chainData.FirstEntity.GetEntityID(); var lastEntity = chainData.LastEntity.GetEntityID(); var firstIsFlipped = chainData.FirstEntityIsFlipped; var lastIsFlipped = chainData.LastEntityIsFlipped; if (firstIsFlipped == false){ var entity = Mastercam.Database.Geometry.RetrieveEntity(firstEntity); if (entity is LineGeometry line){ Point3D lineStartPoint = (line.Data.Point1); Point3D lineEndPoint = (line.Data.Point2); var lineLength = VectorManager.Distance(lineStartPoint, lineEndPoint); var scale = ((lineLength-0.010)/lineLength); entity.Scale(lineEndPoint, scale); entity.Commit(); } if (entity is ArcGeometry arc){ var arcStartPoint = (arc.Data.StartAngleDegrees); var arcEndPoint = (arc.Data.EndAngleDegrees); var arcRad = arc.Data.Radius; var arcLength = ((arcEndPoint - arcStartPoint) * arcRad); var scale = ((arcLength - 0.010)/arcLength); arc.Data.StartAngleDegrees = (arcStartPoint * scale); entity.Commit(); } }
-
That was my exact thinking process. And it works everywhere except on 2 particular chains.
var selectedCutChain = ChainManager.ChainAll(80); foreach (var chain in selectedCutChain){ chain.Direction = ChainDirectionType.Clockwise; var lowerChainLarge = chain.OffsetChain2D(OffsetSideType.Right, .0225, OffsetRollCornerType.None, .5, false, .005, false);
-
I'm still having a rough time creating a consistent offset direction for my chains.
I have tried:
ChainDirectionType
StartChainAtLongest
OrientOpenChainsInDatabaseOrder
chainData.FirstEntityIsFlipped == true
RelinkChainsand various combinations of the listed above.
Using var selectedCutChain = ChainManager.ChainAll(80); and chain.Direction = ChainDirectionType.Clockwise; has gotten me the best result.
Corners A and A match while corners B and B match. (They are all identical geometry). However, corner A does not match corner B.
Out of the 12 chains available, 10 are correct. Even 2 chains that are the exact same.
Any other thoughts to try?
-
For my desired result, would you suggest RollCornerType.None and then fillet all entities?
-
Is there a way to specify what a 'corner' is?
The white line is my starting line and I offset 0.002" both directions for the green and 0.0005" both directions for the pink.
Sometimes it rolls the corners and sometimes it doesn't.
In the photo I've provided it shows that the green was rolled but the pink was not. This becomes an issue when we draft surfaces from the green (makes a pretty round edge) and when we draft surface the pink (have to manually Two Surface Blend).
Is there a way to roll everything? Even things that aren't 'corners'?
var upperChainLarge = chain.OffsetChain2D(OffsetSideType.Right, .002, OffsetRollCornerType.All, .5, false, .005, false);
-
It works. Thank you.
void ChangeOperations(){ var rotaryPD = 0.0; DialogManager.AskForNumber("Enter New Rotary PD", ref rotaryPD); OperationsManager.RefreshOperationsManager(true); var operationIDs = SearchManager.GetOperationIDs(true); var axisParams = new RotaryAxisParams { Enabled = true, Diameter = rotaryPD, Type = RotaryAxisPositionType.AxisSubstitution, Direction = RotaryAxisDirection.CW, AxisSubstitution = RotaryAxisSubstitution.SubsituteY }; foreach (var opID in operationIDs){ var op = SearchManager.GetOperation(opID); op.RotaryAxis = axisParams; op.MarkDirty(); op.Commit(false); } OperationsManager.RefreshOperationsManager(true); } ChangeOperations(); return MCamReturn.NoErrors;
-
-
I thought I was being clever by adding
var array = ((ChainBasedOperation)op).GetChainArray(); op.RotaryAxis = axisParams; ((ChainBasedOperation)op).SetChainArray(array);
But it didn't work I still lose the avoidance region and containment region of the geometry selection.
-
Roger,
That looks like using Data Classes and Functions. Definitely a more efficient way of doing things because of all my broken Syntax.
Your response did help me find the broken code I had.
The ultimate goal, if you look at the .mcam file I sent you, is to take level 75 and create level 200 and 300. (my current program creates the geometry on levels 500-503 so I can compare to the answers (level 200 and 300) provided).
-
I've also tried the 'break' and even the 'goto' but it still only does 0->1->3->#end instead of 0->1->3->2->3->2->3->#end
So I've been thinking it's a syntax error
-
That looks super clean.
How would that look if I wanted to pass data between steps?
This loop checks each entity in the chain, not just the chain. There are 4 possible outcomes so I created four different steps (one to handle each outcome).
If outcome is A -> step 2
If outcome is B -> step 3
If outcome is C -> step 4
If outcome is D -> step 5but after this part, it checks the next entity and sees which outcome is next , thus which step it needs to go to.
This "step" system is just a generic system I'm using to sort each entity until the all the entities in the chain are sorted. Essentially.
-
It now operates halfway. It goes to step 0, step 1, and then step 3, but then it stops on that chain. It's supposed to go to step 2 after that. Ideas?
var step = 0; var chainDetails = new Mastercam.Database.Interop.ChainDetails();// Preps the ChainDetails plugin var selectedChains = ChainManager.ChainAll(75);// Chains all geometry on level 75 var chainDirection = ChainDirectionType.CounterClockwise;// Going to be used to make sure all chains go the same direction ChainManager.StartChainAtLongest(selectedChains); foreach (var chain in selectedChains){ var chainData = chainDetails.GetData(chain); var chainEntityList = chainData.ChainEntities; foreach (var t in chainEntityList){ (t.Key).Color = 9; (t.Key).Commit(); } } foreach (var chain in selectedChains){ templist10.Clear(); step = 0; chain.Direction = chainDirection; var chainEntity = ChainManager.GetGeometryInChain(chain); if (step == 0){ System.Windows.Forms.MessageBox.Show("step 0"); foreach (var entity in chainEntity){ if (entity is ArcGeometry arc && step == 0){ arcX1 = arc.EndPoint1.x; // Arc 1 x 1 arcX2 = arc.EndPoint2.x; // Arc 1 x 2 arcY1 = arc.EndPoint1.y; // Arc 1 y 1 arcY2 = arc.EndPoint2.y; // Arc 1 y 2 arcStartPoint = new Point3D(arcX1, arcY1, 0.0); // Arc 1 start point arcEndPoint = new Point3D(arcX2, arcY2, 0.0); // Arc 1 end point firstEntity = 1; // Saves that first entity is Arc foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point && step == 0){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var arcStartDistance = Math.Abs(VectorManager.Distance(uPoint, arcStartPoint));// Distance between entity start point and crossover point var arcEndDistance = Math.Abs(VectorManager.Distance(uPoint, arcEndPoint));// Distance between entity end point and crossover point if (arcStartDistance <= tolerance && step == 0){ entity.Color = 10;// Changes color of entity to 10 entity.Commit();// Saves entity into Mastercam Database step = 1;// Sets step to 1 templist10.Add(entity.GetEntityID()); } } } } if (entity is LineGeometry line && step == 0){ lineX1 = line.EndPoint1.x; // line 1 x 1 lineX2 = line.EndPoint2.x; // line 1 x 2 lineY1 = line.EndPoint1.y; // line 1 y 1 lineY2 = line.EndPoint2.y; // line 1 y 2 lineStartPoint = new Point3D(lineX1, lineY1, 0.0); // Line 1 start point lineEndPoint = new Point3D(lineX2, lineY2, 0.0); // Line 1 end point firstEntity = 2; // Saves that first entity is Line foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point && step == 0){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var lineStartDistance = Math.Abs(VectorManager.Distance(uPoint, lineStartPoint));// Distance between entity start point and crossover point var lineEndDistance = Math.Abs(VectorManager.Distance(uPoint, lineEndPoint));// Distance between entity end point and crossover point if (lineStartDistance <= tolerance && step == 0){ entity.Color = 10;// Changes color of entity to 10 entity.Commit();// Saves entity into Mastercam Database step = 1;// Sets step to 1 templist10.Add(entity.GetEntityID()); } } } } } } if (step == 1){ System.Windows.Forms.MessageBox.Show("step 1"); foreach (var entity in chainEntity){ if (firstEntity == 1 && step == 1){ var thisEntity = ArcGeometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 1){ arcX1 = arc.EndPoint1.x; // Arc 1 x 1 arcX2 = arc.EndPoint2.x; // Arc 1 x 2 arcY1 = arc.EndPoint1.y; // Arc 1 y 1 arcY2 = arc.EndPoint2.y; // Arc 1 y 2 arcStartPoint = new Point3D(arcX1, arcY1, 0.0); // Arc 1 start point arcEndPoint = new Point3D(arcX2, arcY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.GetEntityID() != templist10[0]) && step == 1){ nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 1){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } if (entityEndDistance <= tolerance && step == 1){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } } if (entity is LineGeometry nextLine && (entity.GetEntityID() != templist10[0]) && step == 1){ nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 1){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } if (entityEndDistance <= tolerance && step == 1){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } } } } if (firstEntity == 2 && step == 1){ var thisEntity = LineGeometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 1){ lineX1 = line.EndPoint1.x; // Arc 1 x 1 lineX2 = line.EndPoint2.x; // Arc 1 x 2 lineY1 = line.EndPoint1.y; // Arc 1 y 1 lineY2 = line.EndPoint2.y; // Arc 1 y 2 lineStartPoint = new Point3D(lineX1, lineY1, 0.0); // Arc 1 start point lineEndPoint = new Point3D(lineX2, lineY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.GetEntityID() != templist10[0]) && step == 1){ nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 1){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } if (entityEndDistance <= tolerance && step == 1){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } } if (entity is LineGeometry nextLine && (entity.GetEntityID() != templist10[0]) && step == 1){ nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 1){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } if (entityEndDistance <= tolerance && step == 1){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } } } } } } if (step == 2){ System.Windows.Forms.MessageBox.Show("step 2"); foreach (var entity in chainEntity){ if (firstEntity == 1 && step == 2){ var thisEntity = ArcGeometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 2){ arcX1 = arc.EndPoint1.x; // Arc 1 x 1 arcX2 = arc.EndPoint2.x; // Arc 1 x 2 arcY1 = arc.EndPoint1.y; // Arc 1 y 1 arcY2 = arc.EndPoint2.y; // Arc 1 y 2 arcStartPoint = new Point3D(arcX1, arcY1, 0.0); // Arc 1 start point arcEndPoint = new Point3D(arcX2, arcY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 2){ nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 2){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } if (entityEndDistance <= tolerance && step == 2){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance){ step = 5; } } } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 2){ nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 2){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } if (entityEndDistance <= tolerance && step == 2){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance){ step = 5; } } } } } } } if (firstEntity == 2 && step == 2){ var thisEntity = LineGeometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 2){ lineX1 = line.EndPoint1.x; // Arc 1 x 1 lineX2 = line.EndPoint2.x; // Arc 1 x 2 lineY1 = line.EndPoint1.y; // Arc 1 y 1 lineY2 = line.EndPoint2.y; // Arc 1 y 2 lineStartPoint = new Point3D(lineX1, lineY1, 0.0); // Arc 1 start point lineEndPoint = new Point3D(lineX2, lineY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 2){ nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 2){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } if (entityEndDistance <= tolerance && step == 2){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance){ step = 5; } } } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 2){ nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 2){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance){ step = 3; } } } } if (entityEndDistance <= tolerance && step == 2){ entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance){ step = 5; } } } } } } } } } // Gets Geo that connects first entity end point to second entity start point (offset 2) if (step == 3){ System.Windows.Forms.MessageBox.Show("step 3"); foreach (var entity in chainEntity){ if (firstEntity == 1 && step == 3){ var thisEntity = ArcGeometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 3){ arcX1 = arc.EndPoint1.x; // Arc 1 x 1 arcX2 = arc.EndPoint2.x; // Arc 1 x 2 arcY1 = arc.EndPoint1.y; // Arc 1 y 1 arcY2 = arc.EndPoint2.y; // Arc 1 y 2 arcStartPoint = new Point3D(arcX1, arcY1, 0.0); // Arc 1 start point arcEndPoint = new Point3D(arcX2, arcY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 3){ nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 3){ entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 3; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance){ step = 2; } } } } if (entityEndDistance <= tolerance && step == 3){ entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 5; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance){ step = 4; } } } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 3){ nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 3){ entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 3; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance){ step = 2; } } } } if (entityEndDistance <= tolerance && step == 3){ entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 5; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance){ step = 4; } } } } } } } if (firstEntity == 2 && step == 3){ var thisEntity = LineGeometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 3){ lineX1 = line.EndPoint1.x; // Arc 1 x 1 lineX2 = line.EndPoint2.x; // Arc 1 x 2 lineY1 = line.EndPoint1.y; // Arc 1 y 1 lineY2 = line.EndPoint2.y; // Arc 1 y 2 lineStartPoint = new Point3D(lineX1, lineY1, 0.0); // Arc 1 start point lineEndPoint = new Point3D(lineX2, lineY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 3){ nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 3){ entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 3; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance){ step = 2; } } } } if (entityEndDistance <= tolerance && step == 3){ entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 5; firstEntity = 1; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance){ step = 4; } } } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 3){ nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 3){ entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 3; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance){ step = 2; } } } } if (entityEndDistance <= tolerance && step == 3){ entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 5; firstEntity = 2; foreach (var v in tempList9){ var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point){ var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance){ step = 4; } } } } } } } } } // Gets Geo that connects first entity end point to second entity start point (offset 1) if (step == 4) { System.Windows.Forms.MessageBox.Show("step 4"); foreach (var entity in chainEntity) { if (firstEntity == 1 && step == 2) { var thisEntity = ArcGeometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 2) { arcX1 = arc.EndPoint1.x; // Arc 1 x 1 arcX2 = arc.EndPoint2.x; // Arc 1 x 2 arcY1 = arc.EndPoint1.y; // Arc 1 y 1 arcY2 = arc.EndPoint2.y; // Arc 1 y 2 arcEndPoint = new Point3D(arcX1, arcY1, 0.0); // Arc 1 start point arcStartPoint = new Point3D(arcX2, arcY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 2) { nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 2) { entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 1; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance) { step = 3; } } } } if (entityEndDistance <= tolerance && step == 2) { entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 1; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance) { step = 5; } } } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 2) { nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 2) { entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 2; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance) { step = 3; } } } } if (entityEndDistance <= tolerance && step == 2) { entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 2; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance) { step = 5; } } } } } } } if (firstEntity == 2 && step == 2) { var thisEntity = LineGeometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 2) { lineX1 = line.EndPoint1.x; // Arc 1 x 1 lineX2 = line.EndPoint2.x; // Arc 1 x 2 lineY1 = line.EndPoint1.y; // Arc 1 y 1 lineY2 = line.EndPoint2.y; // Arc 1 y 2 lineEndPoint = new Point3D(lineX1, lineY1, 0.0); // Arc 1 start point lineStartPoint = new Point3D(lineX2, lineY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 2) { nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 2) { entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 1; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance) { step = 3; } } } } if (entityEndDistance <= tolerance && step == 2) { entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 1; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance) { step = 5; } } } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 2) { nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 2) { entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 2; firstEntity = 2; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance) { step = 3; } } } } if (entityEndDistance <= tolerance && step == 2) { entity.Color = 10; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 4; firstEntity = 2; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance) { step = 5; } } } } } } } } } // Gets Geo that connects first entity start point to second entity start point (offset 2) if (step == 5) { System.Windows.Forms.MessageBox.Show("step 5"); foreach (var entity in chainEntity) { if (firstEntity == 1 && step == 3) { var thisEntity = ArcGeometry.RetrieveEntity(templist10[0]); if (thisEntity is ArcGeometry arc && step == 3) { arcX1 = arc.EndPoint1.x; // Arc 1 x 1 arcX2 = arc.EndPoint2.x; // Arc 1 x 2 arcY1 = arc.EndPoint1.y; // Arc 1 y 1 arcY2 = arc.EndPoint2.y; // Arc 1 y 2 arcEndPoint = new Point3D(arcX1, arcY1, 0.0); // Arc 1 start point arcStartPoint = new Point3D(arcX2, arcY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 3) { nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 3) { entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 3; firstEntity = 1; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance) { step = 2; } } } } if (entityEndDistance <= tolerance && step == 3) { entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 5; firstEntity = 1; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance) { step = 4; } } } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 3) { nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(arcEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(arcEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 3) { entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 3; firstEntity = 2; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance) { step = 2; } } } } if (entityEndDistance <= tolerance && step == 3) { entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 5; firstEntity = 2; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance) { step = 4; } } } } } } } if (firstEntity == 2 && step == 3) { var thisEntity = LineGeometry.RetrieveEntity(templist10[0]); if (thisEntity is LineGeometry line && step == 3) { lineX1 = line.EndPoint1.x; // Arc 1 x 1 lineX2 = line.EndPoint2.x; // Arc 1 x 2 lineY1 = line.EndPoint1.y; // Arc 1 y 1 lineY2 = line.EndPoint2.y; // Arc 1 y 2 lineEndPoint = new Point3D(lineX1, lineY1, 0.0); // Arc 1 start point lineStartPoint = new Point3D(lineX2, lineY2, 0.0); // Arc 1 end point if (entity is ArcGeometry nextArc && (entity.Color != 10) && (entity.Color != 11) && step == 3) { nextArcX1 = nextArc.EndPoint1.x; nextArcX2 = nextArc.EndPoint2.x; nextArcY1 = nextArc.EndPoint1.y; nextArcY2 = nextArc.EndPoint2.y; nextArcStartPoint = new Point3D(nextArcX1, nextArcY1, 0.0); // Arc 2 start point nextArcEndPoint = new Point3D(nextArcX2, nextArcY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextArcStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextArcEndPoint); if (entityStartDistance <= tolerance && step == 3) { entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 3; firstEntity = 1; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcEndPoint); if (entityPointDistance <= tolerance) { step = 2; } } } } if (entityEndDistance <= tolerance && step == 3) { entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 5; firstEntity = 1; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextArcStartPoint); if (entityPointDistance <= tolerance) { step = 4; } } } } } if (entity is LineGeometry nextLine && (entity.Color != 10) && (entity.Color != 11) && step == 3) { nextLineX1 = nextLine.EndPoint1.x; nextLineX2 = nextLine.EndPoint2.x; nextLineY1 = nextLine.EndPoint1.y; nextLineY2 = nextLine.EndPoint2.y; nextLineStartPoint = new Point3D(nextLineX1, nextLineY1, 0.0); // Arc 2 start point nextLineEndPoint = new Point3D(nextLineX2, nextLineY2, 0.0); // Arc 2 end point var entityStartDistance = VectorManager.Distance(lineEndPoint, nextLineStartPoint); var entityEndDistance = VectorManager.Distance(lineEndPoint, nextLineEndPoint); if (entityStartDistance <= tolerance && step == 3) { entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 3; firstEntity = 2; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineEndPoint); if (entityPointDistance <= tolerance) { step = 2; } } } } if (entityEndDistance <= tolerance && step == 3) { entity.Color = 11; entity.Commit(); templist10.Clear(); templist10.Add(entity.GetEntityID()); step = 5; firstEntity = 2; foreach (var v in tempList9) { var w = PointGeometry.RetrieveEntity(v);// Gets point based on GeoID if (w is PointGeometry point) { var ux = point.Data.x;// X location of point var uy = point.Data.y;// Y location of point Point3D uPoint = new Point3D(ux, uy, 0.0);// Saves point location var entityPointDistance = VectorManager.Distance(uPoint, nextLineStartPoint); if (entityPointDistance <= tolerance) { step = 4; } } } } } } } } } // Gets Geo that connects first entity start point to second entity start point (offset 1) } }
-
Brilliant. Confirmed it works. Thank you.
Chain Offset Contour
in Mastercam C-Hook, NET-Hook and VBScript Development
Posted
it is in inch and all the geometry is on the correct level
https://github.com/UberGamz/CustomNethook---Copy