Author Topic: Auto tabs, some code findings....  (Read 921 times)

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 512
    • View Profile
Auto tabs, some code findings....
« on: October 01, 2019, 15:09:53 pm »
At least in 0.9.8 Linux version it works as follows

Code: [Select]
if (lftabs.Count > 0)
            {
                CamBam.ThisApplication.AddLogMessage(" lftabs detected ");
                HoldTab.TabMethod = TabMethodOption.Manual; // For "custom" tabs
                List<HoldingTab> H_Tabs = new List<HoldingTab>();

                foreach (int ID in IDs)
                {
                    Entity primitive = myfile.FindPrimitive(ID);

                    // we assume that the entities are polylines
                    if (primitive.GetType() == typeof(Polyline))
                    {
                        foreach (Line2F l_id in lftabs)
                        {

                            // Test for custom Tabs
                            // left here for future work on it
                            // NOTE: Remember to set "HoldTab.TabMethod" above to Manual

                            Point2F[] int_pt = (primitive as Polyline).LineIntersections(l_id, 0.001f);

                            HoldingTab H_Tab = new CamBam.CAM.HoldingTab();

                            foreach (Point2F pt in int_pt)
                            {
                                Vector2F vnorm = new Vector2F();
                                double parampt = (primitive as Polyline).GetParametricPoint(pt, ref vnorm);
                                H_Tab = new CamBam.CAM.HoldingTab(primitive.ID, parampt, vnorm);
                                H_Tabs.Add(H_Tab);
                            }

                        }

                    }

                }

                // Add Tabs to MOP's "Tabs" property
                mop.Tabs = H_Tabs;


            }


After some hard work I've managed to assign the Tabs Property to the MOPs created in C#.

IDs holds the primitive.ID (integers) of the profiles to be "processed"
lftabs holds a list of Line2F objects as reference lines on which align the tabs

HoldTab is the MOP HoldingTabInfo HoldTab = new HoldingTabInfo(); assigne to the mop asù


mop.HoldingTabs = new CamBam.Values.CBValue<HoldingTabInfo>(HoldTab);

mop is MOPProfile mop = new MOPProfile(myfile, objects);

Attached the results, (almost) good The lines are auto-generated and some intersect the entities in some "corner" places.

Another little brick in Plugins creation

Regards

Carlo D.
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6078
    • View Profile
    • Cambam V1.0 French Doc
Re: Auto tabs, some code findings....
« Reply #1 on: October 01, 2019, 15:21:47 pm »
Hello

Thanks for this research  ;)

I'll move this thread in the plugin help section and add it to the snippet list ;)

++
David
« Last Edit: October 01, 2019, 15:23:36 pm by dh42 »

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 512
    • View Profile
Re: Auto tabs, some code findings....
« Reply #2 on: October 01, 2019, 15:47:37 pm »
Not big thing, once you have coped by the involution of the code :-D.

Some works has to be done, in principle the Line2F List is not the only solution, but as there is a function to obtain the intersection withiout using the polyline intersect function, that return also the "internal" intersection as the start and ending point or coincident points in the polyline as intersection.

Someone has requested the Pointlist, but to obtain a proper pointlist you have to do more calculations coping with the tolerance parameter (I've cheated in the Polyline.LineIntersections, giving a fixed number.

All is rose during my Crenelated Box creation Plugin  to save some material for the cover tenon I've made a function that draw, split and reposition the tenons one near the other, making the tabs position a "critical" game if you wnat to waste no to much material in cutting perimeters.

The image is the result of such work, the trapezoidal polylines are the tenons one near each other. (It works also for polygonal box too, but this is another story as the positioning routine is more mathematical challenging, at least for a non matemathical man like me).

Regards

Carlo D.
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam