Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Recommended Posts

I guess I got it correct. It now returns a list of entities, in order, starting with the entity I mention.

Does it chain the list correctly? Oh absolutely not. TBC!

            List<int> chainSorter(Chain inChain, int startId) {
                var tempListIn = new List<int>();
                var tempListOut = new List<int>();

                var geo = ChainManager.GetGeometryInChain(inChain);
                foreach (var ids in geo){
                    var geoId = ids.GetEntityID();
                    tempListIn.Add(geoId);
                }
                if (tempListIn[0] != startId){
                    bool predicate(int u){
                        if (u == startId){
                            return true;
                        }
                        return false;
                    }
                    var index = tempListIn.FindIndex(predicate);  
                    var listSize = tempListIn.Count;
                    for (var i=index; i<listSize; i++){
                        tempListOut.Add(tempListIn[i]);
                    }
                    for (var i = 0; i < index; i++){
                        tempListOut.Add(tempListIn[i]);
                    }
                }
                return tempListOut;
            }

 

                            var finalList = chainSorter(chain, entity.GetEntityID());
                            var geoList = new List<Geometry>();   
                            foreach (var entity2 in finalList){
                                geoList.Add(Geometry.RetrieveEntity(entity2));
                            }
                            var newChains = ChainManager.ChainGeometry(geoList.ToArray());
                            foreach (var newChain in newChains){
                                var newChainGeo = ChainManager.GetGeometryInChain(newChain);
                                foreach (var testPiece in newChainGeo){
                                    testPiece.Color = 15;
                                    testPiece.Commit();
                                    DialogManager.OK("", "");
                                }
                            }

 

Link to comment
Share on other sites
On 1/6/2023 at 8:49 PM, byte said:

It seems the function does not rely on the order of entities in the array,

 

Instead, wrap add_curve_to_chain, and call that for each entitiy in the chain in the order that you want

Going to be trying this today. If you remember me trying to control the direction of open chains, that's what this is all about.

Sure, they are all open chains, but they don't start that way. All the green need to go towards the inside and all the blue needs to go towards the outside. So all the greens get chained together (open chain) and all the blue get chained together (open chain). But since they start from a closed chain, I can put them in the correct order.

I believe this is the only way to achieve the desired result.

Untitled.png

Link to comment
Share on other sites

The picture I added in the previous post is how everything starts.

It's then separated like this new picture.

Going in a counter clockwise direction around the initial image, one color must be offset one direction and the other color must be offset in the opposite direction.

This is impossible to control with an open chain.

If I can control the order of entities in the chain, I will be able to control the direction of the open chain.

At least that's how things sound in my head 😅

Untitled.png

The code I've come up with so far :: #Rookie Struggles

		static Mastercam::Database::Chain^ SelectionManager::ChainLinker (Mastercam::Database::Geometry^ GEO1){

			bool successful;
			Mastercam::Database::Chain^ returnChain; // NETHook side chain
			CHAIN* tempChain; // CLI side chain
			ent entity; // blank entity
			GetEntityByID(GEO1->GetEntityID(), entity, &successful); // Gets ent value and assigns to entity
			std::vector<ent> entities; // Blank vector list needed for CreateChain method
			entities.push_back(entity); // adds entity to vector list
			tempChain = SelectionManager::CreateChain(entities); // Sends Entity List to chain creator (in order)

			//TODO -> Convert from CHAIN* to Mastercam::Database::Chain^

			return returnChain;
		}
		/// <summary> Construct a Chain from the supplied list of entities. </summary>
		/// <param name="entities"> The (in order!) line and/or arc entities. </param>
		/// <returns> The new chain if successful, else null. </returns>
		/// static CHAIN* SelectionManager::CreateChain(std::vector<ent>& entities){
		static CHAIN* SelectionManager::CreateChain(std::vector<ent>& entities)
		{
			CHAIN* chain;
			short err = alloc_chain(&chain, FALSE /* partial*/);
			bool result = (err == 0 && chain != nullptr);

			if (result)
			{
				CHAIN_ENT* last_chain_ent = nullptr;
				for (auto& entity : entities)
				{
					short errCode = add_curve_to_chain(&entity, 0, TRUE, 0, chain, &last_chain_ent);
					if (errCode != CHAIN_OK) // bail out !
					{
						result = false;
						break;
					}
				}
			}

			return (result ? chain : nullptr);
		}

 

Link to comment
Share on other sites

I'm stumped. How to get a IntPtr from a CHAIN* ??

		static Mastercam::Database::Chain^ SelectionManager::GetNetChain(CHAIN* nativeChain)
		{
			System::IntPtr cPtr = NETHookApiReflection::GetFieldValue(nativeChain, "Data"); //<- Error

			Chain^ chain = nullptr;

			if (cPtr != IntPtr::Zero)
			{
				chain = NETHookApiReflection::ConstructChain(cPtr);
			}

			return chain;
		}

 

Link to comment
Share on other sites

I have made some progress but I’m still stuck. I believe there are two options for what I need, and the help I need is with conversions.

 

Option 1:: Needs conversion from DB_LIST_ENT_PTR ** to DB_LIST_ENT_PTR
Option 2:: Needs conversion from CHAIN* to DB_LIST_ENT_PTR && Needs conversion from DB_LIST_ENT_PTR to IntPtr

            static Mastercam::Database::Chain^ SelectionManager::GetNetChain1(CHAIN* nativeChain)
            {
                  Chain^ returnChain = nullptr;
                  DB_LIST_ENT_PTR** chainPointer;
                  ent chain;
                  ent* entity;
                  bool correct;
                  int* entNumber; 
                  //dbEntityPtr ptr; <- native intPtr

                  chain_to_eptrs(nativeChain, correct, chainPointer, entNumber);
                  get_ent_from_eptr(chainPointer, entity); // <--Needs conversion from DB_LIST_ENT_PTR ** to DB_LIST_ENT_PTR
                  auto geo = Geometry::RetrieveEntity(entity[0].ent_idn);
                  auto geoArray = gcnew System::Collections::Generic::List<Geometry^>();
                  auto chainArray = ChainManager::ChainGeometry(geoArray->ToArray());
                  returnChain = chainArray[0];
                  return returnChain;
            }
            static Mastercam::Database::Chain^ SelectionManager::GetNetChain2(CHAIN* nativeChain)
            {
                  Chain^ returnChain = nullptr;
                  IntPtr point;
                  DB_LIST_ENT_PTR nativeChainPoint;
                  nativeChainPoint = nativeChain; //<--Needs conversion from CHAIN* to DB_LIST_ENT_PTR
                  point = nativeChainPoint; //<--Needs conversion from DB_LIST_ENT_PTR to IntPtr
                  
                  returnChain = NETHookApiReflection::ConstructChain(point);

                  return returnChain;
            }

      Chain^ NETHookApiReflection::ConstructChain (IntPtr ptr)
            {
            Chain^ chain = nullptr;

            if (ptr != IntPtr::Zero)
                  {
                  ConstructorInfo^ ChainConstructor = ReflectChainConstructorInfo();
                  Object^ o = ChainConstructor->Invoke (gcnew array<Object^> { ptr });
                  if (o != nullptr) // Should never be, but just in case...
                        {
                        chain = static_cast<Chain^> (o);
                        }
                  }

            return chain;
            }

 

Link to comment
Share on other sites

First, you have to 'unflip' all the entities or it won't matter.

                var allChains = ChainManager.ChainAll(75);
                foreach (var chain in allChains)
                {
                    chain.Direction = ChainDirectionType.CounterClockwise;
                    var firstGeo = 0;
                    var secondGeo = 0;
                    var step = 0;
                    var tempPoint = new Point3D(0, 0, 0);
                    var tempAngle = 0.0;
                    var chainGeo = ChainManager.GetGeometryInChain(chain);
                    if (step == 0)
                    {
                        firstGeo = chainGeo[0].GetEntityID();
                        step = 1;
                    }
                    if (step == 1)
                    {
                        for (var i = 1; i < chainGeo.Length; i++)
                        {
                            secondGeo = chainGeo[i].GetEntityID();
                            var firstGeoTemp = Geometry.RetrieveEntity(firstGeo);
                            var secondGeoTemp = Geometry.RetrieveEntity(secondGeo);
                            if (firstGeoTemp is LineGeometry line1)
                            {
                                if (secondGeoTemp is LineGeometry line2)
                                {
                                    var firstEndPoint = line1.EndPoint2;
                                    var secondStartPoint = line2.EndPoint1;
                                    if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001)
                                    {

                                        tempPoint = line2.Data.Point1;
                                        line2.Data.Point1 = line2.Data.Point2;
                                        line2.Data.Point2 = tempPoint;
                                        line2.Commit();
                                    }
                                }
                                if (secondGeoTemp is ArcGeometry arc2)
                                {
                                    var firstEndPoint = line1.EndPoint2;
                                    var secondStartPoint = arc2.EndPoint1;
                                    if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001)
                                    {

                                        tempAngle = arc2.Data.StartAngleDegrees;
                                        arc2.Data.StartAngleDegrees = arc2.Data.EndAngleDegrees;
                                        arc2.Data.EndAngleDegrees = tempAngle;
                                        arc2.Commit();
                                    }
                                }
                            }
                            if (firstGeoTemp is ArcGeometry arc1)
                            {
                                if (secondGeoTemp is LineGeometry line2)
                                {
                                    var firstEndPoint = arc1.EndPoint2;
                                    var secondStartPoint = line2.EndPoint1;
                                    if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001)
                                    {

                                        tempPoint = line2.Data.Point1;
                                        line2.Data.Point1 = line2.Data.Point2;
                                        line2.Data.Point2 = tempPoint;
                                        line2.Commit();
                                    }
                                }
                                if (secondGeoTemp is ArcGeometry arc2)
                                {
                                    var firstEndPoint = arc1.EndPoint2;
                                    var secondStartPoint = arc2.EndPoint1;
                                    if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001)
                                    {

                                        tempAngle = arc2.Data.StartAngleDegrees;
                                        arc2.Data.StartAngleDegrees = arc2.Data.EndAngleDegrees;
                                        arc2.Data.EndAngleDegrees = tempAngle;
                                        arc2.Commit();
                                    }
                                }
                            }
                            firstGeo = chainGeo[i].GetEntityID();
                        }
                    }

                }

Then you can send the list(int) of entities to the CLI package

		static Mastercam::Database::Chain^ SelectionManager::ChainLinker (System::Collections::Generic::List<int>^ GeoList){


			bool successful;
			Mastercam::Database::Chain^ returnChain; // NETHook side chain
			CHAIN* tempChain; // CLI side chain
			ent entity; // blank entity
			std::vector<ent> entities; // Blank vector list needed for CreateChain method
			for (auto i=0;i<GeoList->Count;i++){
			GetEntityByID(GeoList[i], entity, &successful); // Gets ent value and assigns to entity
			
			entities.push_back(entity); // adds entity to vector list
			}
			tempChain = SelectionManager::CreateChain(entities); // Sends Entity List to chain creator (in order)
			returnChain = SelectionManager::GetNetChain(tempChain);
			
			return returnChain;
		}

It used CreateChain which adds entities and creates a 'native' chain

		static CHAIN* SelectionManager::CreateChain(std::vector<ent>& entities)
		{
			CHAIN* chain;
			short err = alloc_chain(&chain, FALSE /* partial*/);
			bool result = (err == 0 && chain != nullptr);

			if (result)
			{
				CHAIN_ENT* last_chain_ent = nullptr;
				for (auto& entity : entities)
				{
					short errCode = add_curve_to_chain(&entity, 0, TRUE, 0, chain, &last_chain_ent);
					if (errCode != CHAIN_OK) // bail out !
					{
						result = false;
						break;
					}
				}
			}

			return (result ? chain : nullptr);
		}

We can use GetNetChain to convert it from a 'native' chain to a NetHook chain (using ChainData Interop -- it has NETHookApiReflection)

		static Mastercam::Database::Chain^ SelectionManager::GetNetChain(CHAIN* chain)
		{
			auto newChains = gcnew List<Chain^>();

			//** you created a chain and now use it below
			if (chain)
			{
				for (auto currentChain = chain; currentChain != nullptr; currentChain = currentChain->next)
				{
					IntPtr chainPointer(currentChain);
					auto o = NETHookApiReflection::ConstructChain ( chainPointer );
					if (o != nullptr) // Should never be, but just in case...
					{
						newChains->Add(dynamic_cast<Chain^> (o));
					}
				}
			}

			return newChains[0];
		}

You can now control off offset direction of 'Open Chains'

Link to comment
Share on other sites
18 minutes ago, byte said:

That looks good, one thing to consider when using tolerances is that you may want to handle units if the file was ever in metric, .001 would likely be too small of a tolerance...

 

That'd still be bigger than MTOL 🤣 but you are absolutely correct. I got lucky in this instance, I could've used rounding instead of a tolerance. Doubles are scary.

Link to comment
Share on other sites

Getting an error where sometimes, any chain after the first one, goes clockwise. I'm having a rough time tracking down the root.


            List<int> chainSorter(Chain inChain, int startId) {
                var tempListIn = new List<int>();
                var tempListOut = new List<int>();
                inChain.Direction = ChainDirectionType.CounterClockwise;
                var geo = ChainManager.GetGeometryInChain(inChain);
                foreach (var ids in geo){
                    var geoId = ids.GetEntityID();
                    tempListIn.Add(geoId);
                }
                if (tempListIn[0] != startId){
                    bool predicate(int u){
                        if (u == startId){
                            return true;
                        }
                        return false;
                    }
                    var index = tempListIn.FindIndex(predicate);
                    var listSize = tempListIn.Count;
                    for (var i = index; i < listSize; i++){
                        tempListOut.Add(tempListIn[i]);
                    }
                    for (var i = 0; i < index; i++){
                        tempListOut.Add(tempListIn[i]);
                    }
                    return tempListOut;
                }
                else { return tempListIn; }
            }

 

 

                var freshChain = ChainManager.ChainAll(75);
                foreach(var chain in freshChain){
                    var tempList400 = new List<double>();
                    var chainDetails = new Mastercam.Database.Interop.ChainDetails();// Preps the ChainDetails plugin
                    var chainDirection = ChainDirectionType.CounterClockwise;// Going to be used to make sure all chains go the same direction
                    chain.Direction = chainDirection;
                    var chainGeo = ChainManager.GetGeometryInChain(chain);
                    foreach (var entity1 in chainGeo){
                        var endpoint1 = entity1.EndPoint1.x;
                        var endpoint2 = entity1.EndPoint2.x;
                        var xMedian = (endpoint1+endpoint2)/2;
                        tempList400.Add(xMedian); 
                    }
                    tempList400.Sort();
                    foreach (var entity1 in chainGeo){
                        var templist10 = new List<int>(); // temporarily holds geoID of chainEntities
                        var endpoint1 = entity1.EndPoint1.x;
                        var endpoint2 = entity1.EndPoint2.x;
                        var xMedian = (endpoint1 + endpoint2) / 2;
                        if (xMedian == tempList400[0])
                        {
                            var finalList = chainSorter(chain, entity1.GetEntityID());

 

Link to comment
Share on other sites

I switched to                             for (var i = 0; i < geoList.Count; i++) and it's working now 🤷‍♂️

seems I only have one issue left, for now anyways 🤣 flippedGeometry

I have it inspect the chain, and then reconstruct the chain, but it isn't spitting out in the correct order. I have two start points touching each other, throwing off the entire chain.

            Chain chainFlipper(Chain inChain){
                inChain.Direction = ChainDirectionType.CounterClockwise;
                var firstGeo = 0;
                var secondGeo = 0;
                var step = 0;
                var tempPoint = new Point3D(0, 0, 0);
                var tempAngle = 0.0;
                var chainGeo = ChainManager.GetGeometryInChain(inChain);
                if (step == 0){
                    firstGeo = chainGeo[0].GetEntityID();
                    step = 1;
                }
                if (step == 1){
                    for (var i = 1; i < chainGeo.Length; i++){
                        secondGeo = chainGeo[i].GetEntityID();
                        var firstGeoTemp = Geometry.RetrieveEntity(firstGeo);
                        var secondGeoTemp = Geometry.RetrieveEntity(secondGeo);
                        if (firstGeoTemp is LineGeometry line1){
                            if (secondGeoTemp is LineGeometry line2){
                                var firstEndPoint = line1.EndPoint2;
                                var secondStartPoint = line2.EndPoint1;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001){
                                    tempPoint = line2.Data.Point1;
                                    line2.Data.Point1 = line2.Data.Point2;
                                    line2.Data.Point2 = tempPoint;
                                    line2.Commit();
                                }
                            }
                            if (secondGeoTemp is ArcGeometry arc2){
                                var firstEndPoint = line1.EndPoint2;
                                var secondStartPoint = arc2.EndPoint1;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001){
                                    tempAngle = arc2.Data.StartAngleDegrees;
                                    arc2.Data.StartAngleDegrees = arc2.Data.EndAngleDegrees;
                                    arc2.Data.EndAngleDegrees = tempAngle;
                                    arc2.Commit();
                                }
                            }
                        }
                        if (firstGeoTemp is ArcGeometry arc1){
                            if (secondGeoTemp is LineGeometry line2){
                                var firstEndPoint = arc1.EndPoint2;
                                var secondStartPoint = line2.EndPoint1;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001){
                                    tempPoint = line2.Data.Point1;
                                    line2.Data.Point1 = line2.Data.Point2;
                                    line2.Data.Point2 = tempPoint;
                                    line2.Commit();
                                }
                            }
                            if (secondGeoTemp is ArcGeometry arc2){
                                var firstEndPoint = arc1.EndPoint2;
                                var secondStartPoint = arc2.EndPoint1;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001){
                                    tempAngle = arc2.Data.StartAngleDegrees;
                                    arc2.Data.StartAngleDegrees = arc2.Data.EndAngleDegrees;
                                    arc2.Data.EndAngleDegrees = tempAngle;
                                    arc2.Commit();
                                }
                            }
                        }
                        firstGeo = chainGeo[i].GetEntityID();
                    }
                }
                return inChain;
            }

 

 

 

Link to comment
Share on other sites

If you can confine your for loops to separate functions, I think it's going to help you, all those loops running side by side get confusing

>>

.....

 

What do you mean the two start points are not touching?

You'll have to walk me through what you are doing, the code is incomplete so i don't exactly know whats going on,

 

Link to comment
Share on other sites

If an entity is blue, offset to the left. If an entity is green, offset to the right.

Impossible to control.

But, if the endpoint of the first entity and the start point of the second entity touch, then continue the loop.

If the endpoint of the first entity and the start point of the second entity do not touch, then the entity is 'flipped' and needs to be regenerated so that the two ends switch places.

Everything was working out great, I just didn't realize I had to Retrieve after making all the changes 🤦‍♂️

Link to comment
Share on other sites

Another lesson learned.

If you want to go CCW, the endpoints must be switched. It only grabs the first GEO in the CCW direction.

            Chain chainFlipperCW(Chain inChain){
                inChain.Direction = ChainDirectionType.Clockwise;
                var firstGeo = 0;
                var secondGeo = 0;
                var step = 0;
                var tempPoint = new Point3D(0, 0, 0);
                var tempAngle = 0.0;
                var chainGeo = ChainManager.GetGeometryInChain(inChain);
                if (step == 0){
                    firstGeo = chainGeo[0].GetEntityID();
                    step = 1;
                }
                if (step == 1){
                    for (var i = 1; i < chainGeo.Length; i++){
                        secondGeo = chainGeo[i].GetEntityID();
                        var firstGeoTemp = Geometry.RetrieveEntity(firstGeo);
                        var secondGeoTemp = Geometry.RetrieveEntity(secondGeo);
                        if (firstGeoTemp is LineGeometry line1){
                            if (secondGeoTemp is LineGeometry line2){
                                var firstEndPoint = line1.EndPoint2;
                                var secondStartPoint = line2.EndPoint1;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001){
                                    tempPoint = line2.Data.Point1;
                                    line2.Data.Point1 = line2.Data.Point2;
                                    line2.Data.Point2 = tempPoint;
                                    line2.Selected = false;
                                    line2.Commit();
                                }
                            }
                            if (secondGeoTemp is ArcGeometry arc2){
                                var firstEndPoint = line1.EndPoint2;
                                var secondStartPoint = arc2.EndPoint1;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001){
                                    tempAngle = arc2.Data.StartAngleDegrees;
                                    arc2.Data.StartAngleDegrees = arc2.Data.EndAngleDegrees;
                                    arc2.Data.EndAngleDegrees = tempAngle;
                                    arc2.Selected = false;
                                    arc2.Commit();
                                }
                            }
                        }
                        if (firstGeoTemp is ArcGeometry arc1){
                            if (secondGeoTemp is LineGeometry line2){
                                var firstEndPoint = arc1.EndPoint2;
                                var secondStartPoint = line2.EndPoint1;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001){
                                    tempPoint = line2.Data.Point1;
                                    line2.Data.Point1 = line2.Data.Point2;
                                    line2.Data.Point2 = tempPoint;
                                    line2.Selected=false;
                                    line2.Commit();
                                }
                            }
                            if (secondGeoTemp is ArcGeometry arc2){
                                var firstEndPoint = arc1.EndPoint2;
                                var secondStartPoint = arc2.EndPoint1;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001){
                                    tempAngle = arc2.Data.StartAngleDegrees;
                                    arc2.Data.StartAngleDegrees = arc2.Data.EndAngleDegrees;
                                    arc2.Data.EndAngleDegrees = tempAngle;
                                    arc2.Selected = false;
                                    arc2.Commit();
                                }
                            }
                        }
                        firstGeo = chainGeo[i].GetEntityID();
                        //Geometry.RetrieveEntity(firstGeo).Retrieve();
                    }
                }
                var tempChainGeo = ChainManager.GetGeometryInChain(inChain);
                for (var i = 0; i < tempChainGeo.Length; i++)
                {
                    tempChainGeo[i].Retrieve();
                }
                return inChain;
            }
            Chain chainFlipperCCW(Chain inChain)
            {
                inChain.Direction = ChainDirectionType.CounterClockwise;
                var firstGeo = 0;
                var secondGeo = 0;
                var step = 0;
                var tempPoint = new Point3D(0, 0, 0);
                var tempAngle = 0.0;
                var chainGeo = ChainManager.GetGeometryInChain(inChain);
                if (step == 0)
                {
                    firstGeo = chainGeo[0].GetEntityID();
                    step = 1;
                }
                if (step == 1)
                {
                    for (var i = 1; i < chainGeo.Length; i++)
                    {
                        secondGeo = chainGeo[i].GetEntityID();
                        var firstGeoTemp = Geometry.RetrieveEntity(firstGeo);
                        var secondGeoTemp = Geometry.RetrieveEntity(secondGeo);
                        if (firstGeoTemp is LineGeometry line1)
                        {
                            if (secondGeoTemp is LineGeometry line2)
                            {
                                var firstEndPoint = line1.EndPoint1;
                                var secondStartPoint = line2.EndPoint2;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001)
                                {
                                    tempPoint = line2.Data.Point2;
                                    line2.Data.Point2 = line2.Data.Point1;
                                    line2.Data.Point1 = tempPoint;
                                    line2.Selected = false;
                                    line2.Commit();
                                }
                            }
                            if (secondGeoTemp is ArcGeometry arc2)
                            {
                                var firstEndPoint = line1.EndPoint1;
                                var secondStartPoint = arc2.EndPoint2;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001)
                                {
                                    tempAngle = arc2.Data.EndAngleDegrees;
                                    arc2.Data.EndAngleDegrees = arc2.Data.StartAngleDegrees;
                                    arc2.Data.StartAngleDegrees = tempAngle;
                                    arc2.Selected = false;
                                    arc2.Commit();
                                }
                            }
                        }
                        if (firstGeoTemp is ArcGeometry arc1)
                        {
                            if (secondGeoTemp is LineGeometry line2)
                            {
                                var firstEndPoint = arc1.EndPoint1;
                                var secondStartPoint = line2.EndPoint2;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001)
                                {
                                    tempPoint = line2.Data.Point2;
                                    line2.Data.Point2 = line2.Data.Point1;
                                    line2.Data.Point1 = tempPoint;
                                    line2.Selected = false;
                                    line2.Commit();
                                }
                            }
                            if (secondGeoTemp is ArcGeometry arc2)
                            {
                                var firstEndPoint = arc1.EndPoint1;
                                var secondStartPoint = arc2.EndPoint2;
                                if (VectorManager.Distance(firstEndPoint, secondStartPoint) >= 0.001)
                                {
                                    tempAngle = arc2.Data.EndAngleDegrees;
                                    arc2.Data.EndAngleDegrees = arc2.Data.StartAngleDegrees;
                                    arc2.Data.StartAngleDegrees = tempAngle;
                                    arc2.Selected = false;
                                    arc2.Commit();
                                }
                            }
                        }
                        firstGeo = chainGeo[i].GetEntityID();
                        //Geometry.RetrieveEntity(firstGeo).Retrieve();
                    }
                }
                var tempChainGeo = ChainManager.GetGeometryInChain(inChain);
                for (var i = 0; i < tempChainGeo.Length; i++)
                {
                    tempChainGeo[i].Retrieve();
                }
                return inChain;
            }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...