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:

CopyAndTranslate


Recommended Posts

What am I missing?

 

		static System::Collections::Generic::List<int>^ SelectionManager::BreakArcAtPoint(Mastercam::Curves::ArcGeometry^ arc, Mastercam::BasicGeometry::PointGeometry^ point) {
			
			System::Collections::Generic::List<int>^ newGeoIDs;
			bool successful = false;
			p_3d pointy;
			auto firstEnt = std::make_unique<ent>();
			auto secondEnt = std::make_unique<ent>();
			GetEntityByID(arc->GetEntityID(), *firstEnt, &successful);
			GetEntityByID(point->GetEntityID(), *secondEnt, &successful);

			if (secondEnt->id == P_ID) {
				pointy = secondEnt->u.pt;
			}

			std::vector<ent> firstEntity;
			if (firstEnt->id == A_ID) {
				ent tempEnt;
				tempEnt.id = 'A';
				tempEnt.u.ar.c = firstEnt->u.ar.c;
				tempEnt.u.ar.r = firstEnt->u.ar.r;
				tempEnt.u.ar.sa = firstEnt->u.ar.sa;
				tempEnt.u.ar.sw = firstEnt->u.ar.sw;
				firstEntity.push_back(tempEnt);
			}
			p_3d newArcCenterPoint = firstEntity[0].eptr->eptr->u.ar.c;
			p_3d newArc1StartPoint = firstEntity[0].eptr->eptr->u.ar.ep1;
			p_3d newArc2EndPoint = firstEntity[0].eptr->eptr->u.ar.ep2;
			double newArcRad = firstEntity[0].eptr->eptr->u.ar.r;
			a_2d newArc1;
			a_2d newArc2;
			bool arcCreated;

			constr_arc_new(newArc1StartPoint.ConvertTo2d(), pointy.ConvertTo2d(), newArcCenterPoint.ConvertTo2d(), true, 0.005, &newArc1 ,&arcCreated);
			constr_arc_new(pointy.ConvertTo2d(), newArc2EndPoint.ConvertTo2d(), newArcCenterPoint.ConvertTo2d(), true, 0.005, &newArc1, &arcCreated);

			ent entToStore;
			DB_LIST_ENT_PTR resultGeoID;
			short newSel;
			MC_BYTE mc_byte;
			int newLevel;
			attributes newAttrib;
			bool geoStored;
			store_ent(&entToStore, &resultGeoID, newSel, mc_byte, newLevel, newAttrib, &geoStored,true);//include DbLolo_CH.h

			newGeoIDs->Add(resultGeoID->eptr->ent_idn);
			return newGeoIDs;
		}

 

Link to comment
Share on other sites

Some progress has been made! :D Getting an object error from the constr_arc_new method line. I'm guessing one of the supplied parameters is failing or is unpopulated.

		static System::Collections::Generic::List<int>^ SelectionManager::BreakArcAtPoint(Mastercam::Curves::ArcGeometry^ arc, Mastercam::BasicGeometry::PointGeometry^ point) {
			
			System::Collections::Generic::List<int>^ newGeoIDs;
			bool successful = false;
			p_3d pointy;
			auto firstEnt = std::make_unique<ent>();
			auto secondEnt = std::make_unique<ent>();
			GetEntityByID(arc->GetEntityID(), *firstEnt, &successful);
			GetEntityByID(point->GetEntityID(), *secondEnt, &successful);
			DB_LIST_ENT_PTR resultGeoID1;
			DB_LIST_ENT_PTR resultGeoID2;
			short newSel = ALIVE_BIT;
			MC_BYTE mc_byte = MC_WHITE;
			int newLevel = 75;
			attributes newAttrib;
			bool geoStored;

			if (secondEnt->id == P_ID) {
				pointy = secondEnt->u.pt;
			}

			std::vector<ent> firstEntity;
			if (firstEnt->id == A_ID) {
				ent tempEnt;
				tempEnt.id = 'A';
				tempEnt.u.ar.c = firstEnt->u.ar.c;
				tempEnt.u.ar.r = firstEnt->u.ar.r;
				tempEnt.u.ar.sa = firstEnt->u.ar.sa;
				tempEnt.u.ar.sw = firstEnt->u.ar.sw;
				firstEntity.push_back(tempEnt);
			}
			p_3d newArcCenterPoint = firstEntity[0].eptr->eptr->u.ar.c;
			p_3d newArc1StartPoint = firstEntity[0].eptr->eptr->u.ar.ep1;
			p_3d newArc2EndPoint = firstEntity[0].eptr->eptr->u.ar.ep2;
			double newArcRad = firstEntity[0].eptr->eptr->u.ar.r;
			a_2d newArc1;
			a_2d newArc2;
			bool arcCreated;

			constr_arc_new(newArc1StartPoint.ConvertTo2d(), pointy.ConvertTo2d(), newArcCenterPoint.ConvertTo2d(), true, 0.005, &newArc1 ,&arcCreated);
			if (arcCreated == true) {
				std::vector<ent> firstNewArc;
				ent tempEnt1;
				tempEnt1.id = 'A';
				tempEnt1.u.ar.c = newArc2.c.ConvertTo3d();
				tempEnt1.u.ar.r = newArc2.r;
				tempEnt1.u.ar.sa = newArc2.sa;
				tempEnt1.u.ar.sw = newArc2.sw;
				firstEntity.push_back(tempEnt1);
				store_ent(&firstNewArc[0], &resultGeoID1, newSel, mc_byte, newLevel, newAttrib, &geoStored, true);//include DbLolo_CH.h
				if (geoStored == true) {
					newGeoIDs->Add(resultGeoID1->eptr->ent_idn);
				}
			}
			constr_arc_new(pointy.ConvertTo2d(), newArc2EndPoint.ConvertTo2d(), newArcCenterPoint.ConvertTo2d(), true, 0.005, &newArc1, &arcCreated);
			if (arcCreated == true) {
				std::vector<ent> secondNewArc;
				ent tempEnt2;
				tempEnt2.id = 'A';
				tempEnt2.u.ar.c = newArc2.c.ConvertTo3d();
				tempEnt2.u.ar.r = newArc2.r;
				tempEnt2.u.ar.sa = newArc2.sa;
				tempEnt2.u.ar.sw = newArc2.sw;
				firstEntity.push_back(tempEnt2);
				store_ent(&secondNewArc[0], &resultGeoID2, newSel, mc_byte, newLevel, newAttrib, &geoStored, true);//include DbLolo_CH.h
				if (geoStored == true) {
					newGeoIDs->Add(resultGeoID2->eptr->ent_idn);
				}
			}
			return newGeoIDs;
		}

 

Link to comment
Share on other sites
bool bsuccf = false;
                    DB_LIST_ENT_PTR dbPtr = nullptr;
                    ent nentity;
                    nentity.id = A_ID;
                    nentity.u.ar.c = entity.u.ar.c;
                    nentity.u.ar.r = arcradtoset;
                    nentity.u.ar.sa = entity.u.ar.sa; // Stored in Radians in the database.
                    nentity.u.ar.sw = entity.u.ar.sw; // Stored in Radians in the database.
                    nentity.u.ar.view = entity.u.ar.view;
                    store_ent(&nentity, &dbPtr, ALIVE_BIT, MC_YELLOW, newlevel, main_attrib, &bsuccf);
                    if (bsuccf)
                    {

                    }

something like this

You can also create an arc with dot net ofc

 

void CreateArc(Mastercam::Database::MCView ^ view, const Mastercam::Math::Point3D &point, double radius)
{
    auto arc = gcnew Mastercam::Curves::ArcGeometry();
    arc->View = view; arc->ViewNumber = view->ViewNumber;
    arc->Data.CenterPoint = point;
    arc->Data.Radius = radius;
    arc->Data.StartAngleDegrees = 0.0;
    arc->Data.EndAngleDegrees = 360.0;
    arc->Selected = true;
    arc->Color = 9;
    arc->Commit();
}

Link to comment
Share on other sites

The problem with the easy way is that it'd require math 🤣 The only information I have is the arc data and the point data. I don't know the angle from the center of the circle to the point.

Everything appears to be working, and the level manager shows I have entities created. I just can't see them 🤷‍♂️ And I can't select them. I also can't add their IDs to the return list (it says the IDs don't exist).

 

		static System::Collections::Generic::List<int>^ SelectionManager::BreakArcAtPoint(Mastercam::Curves::ArcGeometry^ arc, Mastercam::BasicGeometry::PointGeometry^ point) {
			
			System::Collections::Generic::List<int>^ newGeoIDs;
			bool successful = false;
			p_3d pointy;
			ent firstEnt;
			ent secondEnt;
			GetEntityByID(arc->GetEntityID(), firstEnt, &successful);
			GetEntityByID(point->GetEntityID(), secondEnt, &successful);
			DB_LIST_ENT_PTR resultGeoID1;
			DB_LIST_ENT_PTR resultGeoID2;
			short newSel = ALIVE_BIT;
			MC_BYTE mc_byte = MC_WHITE;
			int newLevel = 76;
			attributes newAttrib;
			bool geoStored;

			p_3d newArcCenterPoint = firstEnt.eptr->eptr->u.ar.c;
			p_3d newArc1StartPoint = firstEnt.eptr->eptr->u.ar.ep1;
			p_3d newArc2EndPoint = firstEnt.eptr->eptr->u.ar.ep2;
			p_3d breakPoint = secondEnt.eptr->eptr->u.pt;
			a_2d newArc1;
			a_2d newArc2;
			bool arcCreated;

			constr_arc_new(newArc1StartPoint.ConvertTo2d(), breakPoint.ConvertTo2d(), newArcCenterPoint.ConvertTo2d(), true, 0.005, &newArc1, &arcCreated);
			if (arcCreated == true) {
				ent resultArc1;
				resultArc1.id = 'A';
				resultArc1.u.ar.c = newArc1.c.ConvertTo3d();
				resultArc1.u.ar.r = newArc1.r;
				resultArc1.u.ar.sa = newArc1.sa;
				resultArc1.u.ar.sw = newArc1.sw;
				store_ent(&resultArc1, &resultGeoID1, newSel, mc_byte, newLevel, newAttrib, &geoStored, true);//include DbLolo_CH.h
				if (geoStored == true) {
				//	newGeoIDs->Add(resultGeoID1->eptr->ent_idn); <-- Error
				}
			}
			constr_arc_new(breakPoint.ConvertTo2d(), newArc2EndPoint.ConvertTo2d(), newArcCenterPoint.ConvertTo2d(), true, 0.005, &newArc2, &arcCreated);
			if (arcCreated == true) {
				ent resultArc2;
				resultArc2.id = 'a';
				resultArc2.u.ar.c = newArc2.c.ConvertTo3d();
				resultArc2.u.ar.r = newArc2.r;
				resultArc2.u.ar.sa = newArc2.sa;
				resultArc2.u.ar.sw = newArc2.sw;
				store_ent(&resultArc2, &resultGeoID2, newSel, mc_byte, newLevel, newAttrib, &geoStored, true);//include DbLolo_CH.h
				if (geostored == true) {
				//	newgeoids->add(resultgeoid2->eptr->ent_idn); <-- Error
				}
			}
			return newGeoIDs;
		}

 

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...