QComboBox in the Cam Profile ToolPath can't be persistent

Discussions around the CAM Add-On of QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Indicate the post processor used.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
GarfieldTiger
Newbie Member
Posts: 6
Joined: Wed May 24, 2023 6:52 am

QComboBox in the Cam Profile ToolPath can't be persistent

Post by GarfieldTiger » Fri May 26, 2023 2:47 pm

I tried to create a QComboBox in the Cam Profile ToolPath for adding a new property "Cutting Mode", here is the code:

Code: Select all

MyGCode.prototype.postInitDialog = function(obj, dialog, di, obj) {
    var w;

    if (dialog.objectName==="CamProfileToolpathDialog") {
        w = dialog.findChild("CamSpindleSpeed_Label");
        w.visible = false;
        w = dialog.findChild("CamSpindleSpeed");
        w.visible = false;
        w = dialog.findChild("CamSpindleSpeed_Unit");
        w.visible = false;

        w = dialog.findChild("CamPlungeRate_Label");
        w.visible = false;
        w = dialog.findChild("CamPlungeRate");
        w.visible = false;

        w = dialog.findChild("CamFeedRate_Label");
        w.visible = false;
        w = dialog.findChild("CamFeedRate");
        w.visible = false;

        w = dialog.findChild("CuttingDepths_Group");
        w.visible = false;

        var group = dialog.findChild("Toolpath_Group");

        QGridLayout = group.layout();
        var Cuttingmode_Label = new QLabel(qsTr("Cutting Mode"));
        Cuttingmode_Label.objectName = "CamCuttingMode_Label";
        QGridLayout.addWidget(Cuttingmode_Label,2,0);

        var Cuttingmode = new QComboBox();
        Cuttingmode.editable = false;
        Cuttingmode.objectName = "CamCuttingMode";
        Cuttingmode.addItem("NC");
        Cuttingmode.addItem("LC");
        Cuttingmode.addItem("TC");
        Cuttingmode.addItem("MR");
        Cuttingmode.addItem("FB");
        QGridLayout.addWidget(Cuttingmode,2,1);
    }

    if (dialog.objectName==="CamToolDialog") {
       
        w = dialog.findChild("CamSpindleSpeed_Label");
        w.visible = false;
        w = dialog.findChild("CamSpindleSpeed_Unit");
        w.visible = false;
        w = dialog.findChild("CamSpindleSpeed");
        w.visible = false;
        w.setValue(1);

        w = dialog.findChild("CamFeedRate_Label");
        w.visible = false;
        w = dialog.findChild("CamFeedRate");
        w.visible = false;
        w.setValue(1);

        w = dialog.findChild("CamPlungeRate_Label");
        w.visible = false;
        w = dialog.findChild("CamPlungeRate");
        w.visible = false;
        w.setValue(1);
    }
};
Here is the screen shot to show how it looks like:
Cam_Profile_Toopath.png
Cam_Profile_Toopath.png (20.85 KiB) Viewed 7040 times
My problem is no matter what option I choose, the next time I open cam profile toolpath layout, it always sits on "NC".

Could you please help me with this? Thanks

BTW, I am using the version: 3.28.1.0
version.png
version.png (59.95 KiB) Viewed 7039 times

CVH
Premier Member
Posts: 3364
Joined: Wed Sep 27, 2017 4:17 pm

Re: QComboBox in the Cam Profile ToolPath can't be persistent

Post by CVH » Fri May 26, 2023 5:53 pm

Hi,

To my knowledge the CamProfileToolpathDialog doesn't store its settings in QCAD.ini/config.

In detail it serves two purposes:
A) default for a new toolpath.
B) an existent toolpath with its settings stored in the file.

To alter A you probably need to tweak how Cam.js handle these.
We once discovered that for B all settings names must start with "Cam".
https://www.qcad.org/rsforum/viewtopic. ... 015#p39015

Regards,
CVH

GarfieldTiger
Newbie Member
Posts: 6
Joined: Wed May 24, 2023 6:52 am

Re: QComboBox in the Cam Profile ToolPath can't be persistent

Post by GarfieldTiger » Sun May 28, 2023 8:18 am

Thanks, CVH.

Following https://www.qcad.org/rsforum/viewtopic. ... 015#p39015 works for me.

Here is the snippet of the codes:

Code: Select all

MyGCode.prototype.initDialog = function(dialog, di, obj) {
    LaserBase.prototype.initDialog.call(this, dialog, di, obj);
   

    if (dialog.objectName==="CamProfileToolpathDialog") {
        var w;
        w = dialog.findChild("CamSpindleSpeed_Label");
        w.visible = false;
        w = dialog.findChild("CamSpindleSpeed");
        w.visible = false;
        w = dialog.findChild("CamSpindleSpeed_Unit");
        w.visible = false;

        w = dialog.findChild("CamPlungeRate_Label");
        w.visible = false;
        w = dialog.findChild("CamPlungeRate");
        w.visible = false;

        w = dialog.findChild("CamFeedRate_Label");
        w.visible = false;
        w = dialog.findChild("CamFeedRate");
        w.visible = false;

        w = dialog.findChild("CuttingDepths_Group");
        w.visible = false;

        var group = dialog.findChild("Toolpath_Group");

        QGridLayout = group.layout();
        var Cuttingmode_Label = new QLabel(qsTr("Cutting Mode"));
        Cuttingmode_Label.objectName = "CamCuttingMode_Label";
        QGridLayout.addWidget(Cuttingmode_Label,2,0);

        var Cuttingmode = new QComboBox();
        Cuttingmode.editable = false;
        Cuttingmode.objectName = "CamCuttingMode";
        Cuttingmode.addItem("NC");
        Cuttingmode.addItem("LC");
        Cuttingmode.addItem("TC");
        Cuttingmode.addItem("MR");
        Cuttingmode.addItem("FB");
        QGridLayout.addWidget(Cuttingmode,2,1);
    }

    if (dialog.objectName==="CamToolDialog") {
        var w;
        w = dialog.findChild("CamSpindleSpeed_Label");
        w.visible = false;
        w = dialog.findChild("CamSpindleSpeed_Unit");
        w.visible = false;
        w = dialog.findChild("CamSpindleSpeed");
        w.visible = false;
        w.setValue(1);

        w = dialog.findChild("CamFeedRate_Label");
        w.visible = false;
        w = dialog.findChild("CamFeedRate");
        w.visible = false;
        w.setValue(1);

        w = dialog.findChild("CamPlungeRate_Label");
        w.visible = false;
        w = dialog.findChild("CamPlungeRate");
        w.visible = false;
        w.setValue(1);
    }

};


MyGCode.prototype.initEntity = function(entity) {
    LaserBase.prototype.initEntity.call(this, entity);
    this.cuttingMode = this.getToolpathOption("CamCuttingMode", "undefined");

    var today = new Date();
    this.dateTime = formatDate(today, "dd/MMM/yyyy");

}; 

CVH
Premier Member
Posts: 3364
Joined: Wed Sep 27, 2017 4:17 pm

Re: QComboBox in the Cam Profile ToolPath can't be persistent

Post by CVH » Mon May 29, 2023 7:05 am

GarfieldTiger wrote:
Sun May 28, 2023 8:18 am
Following ... works for me.
So the main issue was that the class constructor did not called the base class constructor.
Or MyGCode did not call LaserBase what eventually calls CamExporterV2:

Code: Select all

MyGCode.prototype.initDialog = function(dialog, di, obj) {
    LaserBase.prototype.initDialog.call(this, dialog, di, obj);
    ...
    ..
I don't see any other difference ...

There are things that I don't understand:
- In CamProfileToolpathDialog you remove items by making them invisible and add a ComboBox CamCuttingMode.
- In CamToolDialog you also hide things and set Speed and Feed/Plunge rates to 1.
Ok, a laser doesn't use these but still ... LaserBase already acts on these in postInitDialog ...
- initEntity retrieves the additional CamCuttingMode and that for each exported entity and after the standard initialization.
But does it require to retrieve the date for each exported entity?

Can you explain what the goal is?
What modes: NC, LC, TC, MR and FB are and what happens according CamCuttingMode?

If considered solved then please prefix the title of your first post with [Solved] by editing it.

Regards,
CVH

GarfieldTiger
Newbie Member
Posts: 6
Joined: Wed May 24, 2023 6:52 am

Re: QComboBox in the Cam Profile ToolPath can't be persistent

Post by GarfieldTiger » Mon May 29, 2023 11:12 am

NC, LC, TC, MR and FB means the cutting mode.


In each mode, there is a set of cutting parameters mapping to each cutting mode.

Cutting Speed, Cutting Power and all the other information will be launched after calling each cutting mode in the jobfile, for example:

Code: Select all

PREPARE_NC
BEAMON_NC
The code above will reading the NC cutting parameters in.

The reason In CamToolDialog I hide things and set Speed and Feed/Plunge rates to 1 is without setting Speed and Feed/Plunge, the OK button is disabled as result I can't finish creating a new tool.

In my previous code, I use postInitDialog and for now, initDialog is being used instead.

Yes, I use LaserBase as the base class. Because it defined postInitDialog to rewrite CamProfileToolpathDialog which is done through initDialog , I empty its implementation in my inherited class.

Post Reply

Return to “QCAD/CAM”