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:

JKLINE

Verified Members
  • Posts

    166
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

JKLINE's Achievements

Collaborator

Collaborator (7/14)

  • Dedicated Rare
  • One Month Later
  • Collaborator Rare
  • Week One Done
  • Reacting Well Rare

Recent Badges

0

Reputation

  1. I would also join one forum up (this subgroup is for C-Hooks and such). There appears to be more support and activity there for Post related activities.
  2. nethookdocs will have the majority of your tooltips/hints. https://nethookdocs.mastercam.com
  3. I'm thinking perhaps collecting the Geometry and then making my own chain. Running into a problem though, with the geometry not changing direction. I need the geometry to have the endpoint1 and endpoint2 be that way on the first and then for it to read endpoint2 to endpoint1. I think it's having trouble because there's only one entity.
  4. I could use some help with creative thinking. If you have an X shape or t shape object, and you want to offset the chains to make them all closed and rounded edges, you can use the SLOT result method. The issue is that they leave an overlap so you cannot use the result chain. Untitled3 shows trouble area Untitled2 shows how the offset curves around end untitled1 shows the beginning shape example.
  5. 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; }
  6. 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
  7. foreach(var alteredGeo in alteredGeoList) { alteredGeo.Retrieve(); } Bleh
  8. 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; }
  9. I've made sure that GeoList is storing the numbers correctly. They are all in the correct order. But when I go to use 'foreach var entity in GeoList' it doesn't stay in order. Should I just switch to for i=0 ect ect?
  10. 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());
  11. resultArc1.id = 'A'; needs to be resultArc1.id = A_ID; How embarrassing Works like a charm.
  12. 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; }
  13. Some progress has been made! 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; }
  14. 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; }

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