Create and display local coordinate system

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
saso
Posts: 1586
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Create and display local coordinate system

Postby saso » Thu Dec 20, 2018 11:50 am

Well my first argument for it would be that mostly all parametric cad systems have it, here is a quick search around the internet for some screenshots of nx, creo, inventor, solidworks, catia (see videos before),... I am sure other have it also.

Use cases... I guess more or less all use cases that airplanes are used for in Lattice; things seen in the few catia videos I have posted in this topic; Zolko's case for Part placement in assemblies; Pauvres_honteux also talked about this before https://forum.freecadweb.org/viewtopic. ... 79#p140379 (check also pdf's),...

<Edit>I guess it can be useful also for Path WB, to set different, user defined coordinate systems, for cnc machines...<End of edit>

I guess to understand csys compared to existing datum elements (point, planes, lines) one can think about the different degrees of freedom that each of them sets for the user, a point in space defines the three coordinates (x,y,z) but generally does not define the orientation; a plane defines the orientation and one coordinate (lets say z) the other two (x,y) are defined when something is placed on that plane; an csys defines everything... sort of :roll:
Attachments
solidworks.png
solidworks.png (18.47 KiB) Viewed 1147 times
inventor.png
inventor.png (19.64 KiB) Viewed 1147 times
creo.png
creo.png (28.73 KiB) Viewed 1147 times
nx.png
nx.png (12.44 KiB) Viewed 1147 times
Last edited by saso on Tue Aug 06, 2019 11:56 pm, edited 3 times in total.
Jee-Bee
Posts: 2145
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Create and display local coordinate system

Postby Jee-Bee » Thu Dec 20, 2018 12:20 pm

I would say for my self. i use coordinate system most to define placement on higher/ lower level.
I use it less often for modeling purposes.
but in any case why are creating datum planes and datum axis seen as an need but is a datum coordinate system not needed.
all datum features have it's own (personal) use case. off course some are used more often but i think all should be implemented.
saso wrote:
Thu Dec 20, 2018 9:05 am
What I would find even much much better is if all of them (point, line, plane, cs) would be changed so that they can be used generally (not just in Body),...
I agree on this. Maybe we should make an separate topic from this. that it don't get lost in this topic and it's more easy to find it back.
User avatar
Zolko
Posts: 1097
Joined: Mon Dec 17, 2018 10:02 am

Re: Create and display local coordinate system

Postby Zolko » Thu Dec 20, 2018 5:17 pm

saso wrote:
Thu Dec 20, 2018 9:05 am
CoordinateSystem seems functional and usable to me, can it be added to the gui?
Did you find where to enable this in the sourcecode, or was that screenshot photoshopped ?
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
User avatar
DeepSOIC
Posts: 7829
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Create and display local coordinate system

Postby DeepSOIC » Thu Dec 20, 2018 9:14 pm

saso wrote:
Thu Dec 20, 2018 11:50 am
I guess more or less all use cases that airplanes are used for in Lattice; things seen in the few catia videos ...
... can be useful also for Path WB, to set different, user defined coordinate systems, for cnc machines..
Well, these are potential uses, not ones that we get working for free (well, except I made Lattice support them already). As a result, the request to include them into 0.18 that is probably to be released soon seems strange: we get a thing that doesn't do much, yet has a lot of potential... kinda disappointing.

But it can be done... after all, something can be much better than nothing. I'm for! Who's up to write the code?
User avatar
Zolko
Posts: 1097
Joined: Mon Dec 17, 2018 10:02 am

Re: Create and display local coordinate system

Postby Zolko » Fri Dec 21, 2018 9:39 am

DeepSOIC wrote:
Thu Dec 20, 2018 9:14 pm
But it can be done... after all, something can be much better than nothing. I'm for! Who's up to write the code?
In the file ~/src/Mod/PartDesign/Gui/Resources/PartDesign.qrc there is mention of <file>icons/PartDesign_CoordinateSystem.svg</file> , and indeed the icon file exists. Therefore I believe it's only a matter of enabling the button.

Then there is another subject about the LCS: it is visually defined in ~/src/Mod/PartDesign/Gui/ViewProviderDatumCS.cpp, in "void ViewProviderDatumCoordinateSystem::attach ( App::DocumentObject *obj )". It is not very satisfactory.

But a much nicer LCS implementation exists, it's called AxisCross, and can be (visually) enabled in the menu "View → Toggle axis Cross". That is defined in ~/src/Gui/View3DInventorViewer.cpp, in the function "void View3DInventorViewer::setAxisCross(bool on)"

If it were be possible to use the same visual for the LCS as for AxisCross, it would be awesome.
Attachments
LCS_AxisCross.png
LCS_AxisCross.png (190.84 KiB) Viewed 1032 times
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
User avatar
saso
Posts: 1586
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Create and display local coordinate system

Postby saso » Sat Dec 22, 2018 8:57 am

Zolko wrote:
Thu Dec 20, 2018 5:17 pm
saso wrote:
Thu Dec 20, 2018 9:05 am
CoordinateSystem seems functional and usable to me, can it be added to the gui?
Did you find where to enable this in the sourcecode, or was that screenshot photoshopped ?
It was Gimped ;) For testing and playing I am ok with the command line, so I will wait to hopefully see an official solution for the gui, but if you really want it you can add it as a macro.
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: Create and display local coordinate system

Postby triplus » Sat Dec 22, 2018 10:39 pm

Likely, as it was suggested back then, we should have introduced a coordinate system feature named Coordinate system. We named it Part feature instead, and have left the door for ambiguity wide open.
User avatar
Zolko
Posts: 1097
Joined: Mon Dec 17, 2018 10:02 am

Re: Create and display local coordinate system

Postby Zolko » Mon Jan 07, 2019 8:27 pm

saso wrote:
Thu Dec 20, 2018 9:05 am
CoordinateSystem seems functional and usable to me, can it be added to the gui? Please :) At least as the other datum elements in the Part Design to be used in the Body
gotcha, succeeded at last:

Create_LCS.png
Create_LCS.png (344.07 KiB) Viewed 854 times

And it's not GIMP'ed either (well, apart from the red circle). Unfortunately, I don't completely remember what did the thing, because I've been modifying loads of files. If someone wants to try, it's at least in the file ~/src/Mod/PartDesign/Gui/Command.cpp, and you have to duplicate the section about "Datum feature commands", and add before DEF_STD_CMD_A(CmdPartDesignPlane);

Code: Select all

DEF_STD_CMD_A(CmdPartDesignCS);

CmdPartDesignCS::CmdPartDesignCS()
  :Command("PartDesign_CoordinateSystem")
{
    sAppModule      = "PartDesign";
    sGroup          = QT_TR_NOOP("PartDesign");
    sMenuText       = QT_TR_NOOP("Create a local coordinate system");
    sToolTipText    = QT_TR_NOOP("Create a new local coordinate system");
    sWhatsThis      = "PartDesign_CoordinateSystem";
    sStatusTip      = sToolTipText;
    sPixmap         = "PartDesign_CoordinateSystem";
}

void CmdPartDesignCS::activated(int iMsg)
{
    Q_UNUSED(iMsg);
    UnifiedDatumCommand(*this, Base::Type::fromName("PartDesign::CoordinateSystem"),"LCS");
}

bool CmdPartDesignCS::isActive(void)
{
    if (getActiveGuiDocument())
        return true;
    else
        return false;
}
also, at the end, in CreatePartDesignCommands, add

Code: Select all

rcCmdMgr.addCommand(new CmdPartDesignCS());

and recompile.
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
User avatar
Zolko
Posts: 1097
Joined: Mon Dec 17, 2018 10:02 am

Re: Create and display local coordinate system

Postby Zolko » Mon Jan 07, 2019 8:54 pm

Zolko wrote:
Mon Jan 07, 2019 8:27 pm
If someone wants to try, it's at least in the file ~/src/Mod/PartDesign/Gui/Command.cpp

... and you also have to add them to the menu and toolbar, in ~/src/Mod/PartDesign/Gui/Workbench.cpp, add in Gui::MenuItem* Workbench::setupMenuBar and in Gui::ToolBarItem* Workbench::setupToolBars

Code: Select all

Gui::MenuItem* Workbench::setupMenuBar() const
...
<< "PartDesign_Plane"
<< "PartDesign_CoordinateSystem"

Code: Select all

Gui::ToolBarItem* Workbench::setupToolBars() const
...
<< "PartDesign_Plane"
<< "PartDesign_CoordinateSystem"
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
freecad-heini-1
Posts: 7366
Joined: Tue Jan 07, 2014 11:10 am
Contact:

Re: Create and display local coordinate system

Postby freecad-heini-1 » Sat Jan 12, 2019 3:01 pm

Zolko wrote:
Mon Jan 07, 2019 8:27 pm
saso wrote:
Thu Dec 20, 2018 9:05 am
CoordinateSystem seems functional and usable to me, can it be added to the gui? Please :) At least as the other datum elements in the Part Design to be used in the Body
gotcha, succeeded at last:


Create_LCS.png


And it's not GIMP'ed either (well, apart from the red circle). Unfortunately, I don't completely remember what did the thing, because I've been modifying loads of files. If someone wants to try, it's at least in the file ~/src/Mod/PartDesign/Gui/Command.cpp, and you have to duplicate the section about "Datum feature commands", and add before DEF_STD_CMD_A(CmdPartDesignPlane);

Code: Select all

DEF_STD_CMD_A(CmdPartDesignCS);

CmdPartDesignCS::CmdPartDesignCS()
  :Command("PartDesign_CoordinateSystem")
{
    sAppModule      = "PartDesign";
    sGroup          = QT_TR_NOOP("PartDesign");
    sMenuText       = QT_TR_NOOP("Create a local coordinate system");
    sToolTipText    = QT_TR_NOOP("Create a new local coordinate system");
    sWhatsThis      = "PartDesign_CoordinateSystem";
    sStatusTip      = sToolTipText;
    sPixmap         = "PartDesign_CoordinateSystem";
}

void CmdPartDesignCS::activated(int iMsg)
{
    Q_UNUSED(iMsg);
    UnifiedDatumCommand(*this, Base::Type::fromName("PartDesign::CoordinateSystem"),"LCS");
}

bool CmdPartDesignCS::isActive(void)
{
    if (getActiveGuiDocument())
        return true;
    else
        return false;
}
also, at the end, in CreatePartDesignCommands, add

Code: Select all

rcCmdMgr.addCommand(new CmdPartDesignCS());

and recompile.
Whow, after a while the axis cross is here. Very nice, Thank's to the developer.