CamBam

Support => Related Softwares => Topic started by: onekk on October 06, 2018, 10:53:42 am



Title: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 06, 2018, 10:53:42 am
Hi to all I put here the new files.

It seem's it more taylore to have here:

Some correction on code and some improvement:

1) text files are not finished yet

2) the transformation matrix is not supported yet

3) mesh aren't supported yet

REgards

Carlo D.



Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 06, 2018, 15:16:31 pm

Now I'm searching for a code that return me the CW and CCW giving the costruction point of the polylines (and rectangles that internally hold the polylines too)

Regards

Carlo D.


Have a look here; http://www.cambam.info/doc/api/Polyline.htm


test cb file loaded okay, see attached image


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 07, 2018, 01:16:27 am
OK i have to investigate the API.

Thanks

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 07, 2018, 02:09:28 am
Hi Carlo

I tested the file and geometry,by making the primitives required by the various workbenches.

All the tests worked and I was able to make 3d objects from the imported geometry.

With the text I found that there is a setting in the panel to change the behavior of the text in the view.
either 2D or 3D.
There's a difference between an Annotation text and a Label text.
All in All it's going very well.
Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 08, 2018, 11:39:33 am
Hi dave benson

In fact the text in FC is of two types, Annotations, (which iapparently didn't scale with the image)

The Shapestring (which I'm inclined to use as it retain the size you gave at the creation), but there are some question to answer:

- The font in CamBam, is used mainly for annotations (or maybe I'm wrong?) when I use for other thing, I transform the text in a polyline, maybe using outline for cutting out from wood.

I have not used yet the engrave MOP (if I remember well this is the other use of a text "as is" in CamBam)

- The font path in Linux and Windows are different so a manner to manipulate them is needed,
This problem aplly also to the font name and style (as in Linux there are many variant, other than Bold, italic and "regular")

The Shapestring is a shape so it is possible to obtain a bounding box and so make the created text respect the alignement property of CamBam, but this create a shape (a solid of 0 height, if I'm starting to learn FreeCAD properly)

What text we have to use? more research are needed or maybe some hints are required from future users of this "little piece of software".

As I haven't used yet the engrave MOP "porting" the text in FC is marginal, so the "translation" problems are not very  high in my TODO list.

But suggestion are very welcomed.

As a side note, I've sorted out a manner to fill the CCW and CW property using some math testing the "order" of the first three points using a numpy matrix and a formula found on WikiPedia https://en.wikipedia.org/wiki/Curve_orientation#Orientation_of_a_simple_polygon (https://en.wikipedia.org/wiki/Curve_orientation#Orientation_of_a_simple_polygon)

And it seems almost correct, but for at least three points, for two point maybe a simple test x0-x1 and y0-y1 is sufficient.

Regards

Carlo D.
 


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 08, 2018, 14:15:41 pm
Can you please confirm that these are the steps required;

1. start FreeCAD
2. from the drop down that says "Start" select "OneCAM"
3. three icons appear, select icon "Load a CamBam File to process"
4. choose the test file called "test_obj.cb"
5. select icon, "Import All CB Entities to FC"
6. the entities appear.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: pixelmaker on October 08, 2018, 20:16:34 pm
I tried to get OneCAM to work today.
The working environment appears, I can select it, but when I select it I only get an error message:

PySide2.QtWidgets.QHeaderView' object has no attribute 'setResizeMode'

I can't see any buttons, I can´t do anything with the workbench.

mac osx 10.11.6, FreeCAD 0.17

ralf


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 08, 2018, 20:40:41 pm
Ralf,

I believe the error refers to the Qt cross platform SDK that is used with FreeCAD.

I'm using Windows so this is just a guess at how the mac looks.

In the "OneCAM-FreeCAD" folder there is a file called "OCB_Gui.py" and in there you should find two instances of, "setResizeMode". If you can use an editor such as Notepad++, change those two instances to, "setSectionResizeMode", save the file then try to restart FreeCAD.

On my system, "setResizeMode" works but "setSectionResizeMode" does not  ???

If you search the net for "setSectionResizeMode" and "setResizeMode" more information will come to light, it seems one of those is an old function and it depends upon the version of Qt installed.

In FreeCAD if you go to, Help->About->Libraries, it will show the version of Qt, mine is Qt 4.8.7 if your is Qt 5 then that may explain it.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 08, 2018, 22:36:39 pm
Hi to all.


For pixelmaker  FreeCAD 0.17 use the Qt 4.8 and not the Qt5.0 at least on Linux and I suppose Windows, PySide2 is Qt5 specific.

Maybe Mac OS use the Qt5 even for the 0.17 (That at lest in Linux is Python2 and Qt 4.8 based).

Mac OS with FreeCAD has much problems than Linux and Windows, as many post on the FreeCAD Forum seems to reveal.

EddyCurrent the expected behaviour of OneCAM is those you described, the plus button on the toolbar will "translate" the selected CamBam entity in one "new" group named "default" (sorry for the lack of originality) despite the original layer name and permit to copy many time the same entity, modifying the "object" name accordingly (trying to guess the name that FC has assigned to avoid name conflict).

This is maybe a "strange" behaviour, but during the development I have used it to test some FreeCAD internals so it is here.

The Import work is done in two phases in the first phase the CB file is read and the CAD entities are shown on the CamBam Tab, this permit to extract the ID that is used in the "import" phase to extract from the XML Etree loaded in memory (maybe not very efficient, but the xml.etree in python could be used in different manners).

More improvement are possible, and the usefullness of this piece of software for now has to be taken as a work in progress i hope driven from the CB community interest.  

Thanks to all for the help (even the test is an invaluable help), feel free to let me know what do you think and maybe if you use it with other files than the test file included, if possible put this files included in your post.

For now the transformation matrix isn't taken in account, as I have no real examples of it in my CB files, if someone is kindly enough to send me a CB file with a real transformation matrix, i will attempt to implement it.

As you maybe haven't noted there is some difference in the file displayed in the "CamBam" Tab on FreeCAD, and they are related to the information that the CB XML file holds in it, in "PolyRectangle" the creation point are present in the XML structure and these information are used to draw the entity in FreeCAD, the rectangle is not "calculated" by the program but the "Polyline points" information in the CB XML file are used,, resolving the bulge factor to "implement" the "rounded corner" property on CamBam.

Maybe I will put also the "Region" information that internally have the OuterCurve Polyline and the "holecurves" polyline internally representes simply as "Polylines".

Regards

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 09, 2018, 09:10:46 am
pixelmaker

I'm investigating a mean to take in account those differences, but as I have not Mac OS for testing the code, if you can test my modification ASA I've impletemented them, thanks to EddyCurrent I hope to be able to put some test about the Qt version used or the presence of Pyside2 (that is related to Qt5)

The qt version is reported by PySide i have to check how to import the correct PySide and check the Qt version.

Stay tuned and Regards

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: BR52 on October 10, 2018, 20:58:45 pm
Hello Ralf,

I am not user of mac osx.
In FreeCAD already have PySide embedded with your library.
So you do not need to install the PySide.

Whoever develops other App using PySide, has to install PySide.
https://pypi.org/project/PySide/
With the "python pip install PySide" command.

     Please see the two screenshot.

   Armando


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: pixelmaker on October 11, 2018, 09:34:18 am
Inside the FreeCAD.app/Contents/lib/python2.7/sidepackages there are two folders, one named PySide2 and the other Pyside2uic. The contents of the folders can be seen on the screenshots. The path can be seen at the bottom of the window. I can't find PySide on my computer, just PySide2

ralf


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 11, 2018, 14:56:04 pm
I should have mentioned I'm using Freecad 0.18 as recommended by Dave Benson here; http://www.cambam.co.uk/forum/index.php?topic=7579.msg61167#msg61167


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: BR52 on October 11, 2018, 15:53:05 pm
In the "../Mod/OneCAM-FreeCAD" folder there is a file called "OCB_Gui.py"

Open the file in the text editor change the line with "from PySide import QtCore, QtGui" to
"from PySide2 import QtCore, QtGui", save the file.

In the "../Mod/OneCAM-FreeCAD" folder, Delete all files with *.pyc extension if exists.

                                Run FreeCad.

   Armando



Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 11, 2018, 23:05:34 pm
The problem is more related to the way FreeCAD has used PySide.

I'm using 0.17 and internally it uses Qt4 and Pyside (that are the binding for Qt4) and Python2.

0.18 uses Qt5 and PySide2 and Python3.

The main concern is that I'm using Devuan Ascii (Same base as Debian Stretch but without SystemD) and it is using QT4 and Python2, even if the AppImage of 0.18 is using the new versions, of Qt5 and Python3, there are some reports that says that in Debian the new 0.18 is causing troubles.

As I don't want to download 250 and more MB of the new 0.18 AppImage for now, I have to investigate these reports, as I'm on a paid WiFi internet connection (No decent cables services in my town) i have to be careful on Bandwidth.

I'm working on taking in account the PySide2 thing but I need some support.

In the next days, maybe after the WE i will post a "new" beta of this workbench.

Thanks to all and Regards

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 12, 2018, 01:46:13 am
Hi All
To be clear, I've done all my testing with 0.17 as that's what Carlo's using, but as a "Daily Driver" I use 0.18 as I'm very Interested in the A2plus Workbench and there are
differences between 0.17 and 0.18 (improvements)  not least of which is the QT5 and Python3.

Because I started early with Freecad, a lot of my drawings needed to be migrated to 0.17 and 0.18  from 0.15 and 0.16

One of the biggest pitfalls is to have a "sketch attached to a face" rather than a Datum plane (this is ok for simple geometry that's not going to change later on in the drawing)
But if you modify the face (that your sketch is attached too) later on in the drawing, and there's no longer any solid surface under the sketch your drawing will break.

IF you are going to use Sketches you should start your drawing with a PART and a BODY,  this way you can use the transform tools which don't show up in the
drop down menus  otherwise.

Quote
From the Freecad site:

Advice for creating stable models
The idea of parametric modeling implies that you can change the values of certain parameters and subsequent steps are changed according to the new values.
However, when severe changes are made, the model can break due to the topological naming issue that is still unresolved in FreeCAD.
Compared to previous FreeCAD versions, breakage can be minimized when you respect the following design principles:

Avoid as much as possible mapping sketches to faces of the model. Place your sketches on standard planes, or on custom datum planes.
Sketches attached to planes are less at risk of being unexpectedly reattached to a different reference.
When creating datum geometry, do not base it on the part topology, base it on standard planes/axes and/or sketches.
Use a "master sketch". That is a preferably not too complicated sketch which contains basic geometric elements of your model.
These elements can be referenced when modeling subsequent features.
Such a master sketch will often be the first sketch in the Body but it doesn't have to be; in fact you don't even have to use it at all for anything else but being referenced.
If you inevitably have to reference an intermediate feature, e.g. the result of a thickness operation, use the first reference possible in the list of subsequent features
where the referenced geometric element occurs. From FreeCAD 0.17 on you don't have to use the latest feature.
If you take an early feature as reference, all changes to intermediate steps won't break your model.
And again it is better to reference a sketch than edges and vertices of a solid.

Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 12, 2018, 11:21:09 am
The only reason I installed FreeCAD was to help Carlo with his project, my CAD software is actually Rhino 3D.
With that in mind, is it better if I install FreeCAD 0.17 or FreeCAD 0.18 ?


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 12, 2018, 13:56:33 pm
HI Eddy
I just tried 0.18 and compared it with 0.17 and as far as I can tell they perform equally well.
So Perhaps you could continue with 0.18 and I will continue with 0.17, for windows at least, Freecad
behaves pretty well, but there may be more issues across  different OS's rather than between versions.
There are many flavors of Linux and I think this is where the trouble lays.
Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 12, 2018, 23:15:31 pm
HI Eddy
I just tried 0.18 and compared it with 0.17 and as far as I can tell they perform equally well.
So Perhaps you could continue with 0.18 and I will continue with 0.17, for windows at least, Freecad
behaves pretty well, but there may be more issues across  different OS's rather than between versions.
There are many flavors of Linux and I think this is where the trouble lays.
Dave

Hi Dave benson, in Linux, the AppImage is a good way to go, to avoid many problems, only a quite recent libc and X are required and used by FreeCAD, all the remaining libraries are included in the AppImage (as you can see if you decompress it as I've done).

The thing is different if you plan to develop, as version of Qt compatible with those installed is needed to build the Interface builder i.e. to develop a "preferences" Tab under FreeCAD.

And this is a problem because you have to compile FreeCAD from scratch only to use the part used by Qtcreator to build the dialogs that have to be incorporated in some place of the FreeCAD interface.

In my case using Devuan (the packages are the same as Debian Stretch) and not Ubuntu make the thing quite difficult and time consuming (To compile FreeCAD from scratch you have to compile many "base" libraries like OCE and VTK much newer than those shipped with the OS).

This is the little I know about FreeCAD (for now, i hope to know more in the future).

My working is in progress (a little late as I'm developing some little things on CamBam, and I need to "retarget" my brain to C#), and I plan to release the new beta next week. This WE is very busy due to family "work".

TIA for the interest to all and Regards

Carlo D.

 


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: pixelmaker on October 13, 2018, 13:47:52 pm
In the "../Mod/OneCAM-FreeCAD" folder there is a file called "OCB_Gui.py"

Open the file in the text editor change the line with "from PySide import QtCore, QtGui" to
"from PySide2 import QtCore, QtGui", save the file.

In the "../Mod/OneCAM-FreeCAD" folder, Delete all files with *.pyc extension if exists.

                                Run FreeCad.

   Armando



Done, now I get a new error if I choose the OneCAM Workbench: 'module' object has no attribute 'qApp'

ralf


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 14, 2018, 10:27:05 am
There are some differences between Qt4 and Qt4 despite the fact Qt5 manifest says that the migration from Qt4 to Qt5 is easy.

Many Widgets are migrated from QtGui to Qwidget so the transition is not difficult.

sayd so, I have to use the Qt4 version as my distribution is using it but i plan to see if it feasible to work even with 0.18 in the "near future".

For now it is a heavy experimental "piece of code", mostly an exercise to learn FreeCAD internals to make WorkBenches, but as it is decently usable to make simple works, as the main goals is to import CamBam entities and related them with MOPs to obtain a 3D extrusion of the pieces to work on them with FreeCAD tools.

These pieces are meant to be cut with my hobby router table so are simply 2.5D operation with no exotic things, mostly pocket and profiles.

Plus as FreecAD itself is a WIP code, and many internals are not well documented (slightly better than in CamBam, but not fully diocumented yet and "subject to change") my help on some errors are limited to be able to reproduce on my "working machine"

I'm working on a version that could take account of some differences between Qt4 and Qt5, via some "if then else" in the problematic pieces of code but I need help with OS and version different from those I use, Linux and 0.17 AppImage.

To worse the things, in Linux there are many "distributions" and some of them make the things difficult by packaging they own version of the program patching the code to make it work on the actual combination of libraries "officially supported" by the distribution, so the AppImage is a safe foundation to work on.

So the AppImage is based on a some basic "component" like the glibc and X infrastructure, where the things are more stable and not changing too soon. The relevant libraries such Qt(4 or 5) and OCE and Coin and Python and so on are contained in the AppImage, plus you can decompress it and see the "building tree".

All said is to explain to those don't know how the thing are working under the hood of many actual "pieces of codes" around.

Thanks for your help and interest on this "experiment".

Soon I will publish a copy of OneCAM with the "MOP data extraction" working, I'm developing the "working code" to extract them from the xml file.

Regards

Carlo D.






Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 15, 2018, 18:12:22 pm
New beta:

Maybe some chances that it will work on Qt5 (I've put a line that is used to discovery the qt version) and added two check when creating some widget.

Added the first attempt to parse the MOPs, for now it is limited to a simple display of the part an mops (profile and pocket for now) and retirieve and display "name and related primitives"

TIA for the comments and test and my best Regards to all.

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 15, 2018, 18:49:19 pm
Works okay on;

Windows 10
FreeCAD 0.18
Qt 4.8.7
Python 2.7.14
Pyside

But it sounds like we need a new cb test file with MOps


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 16, 2018, 00:44:17 am
I was sure I've have put a new file in the zip file, but after some check you are right, maybe my script isn't working well.

happy to see it is working even on 0.18, strange enough it seems that 0.18 running on Win10 use the old qt4, and python 2.7.

In Linux is reported to use Qt5 and python 3.6 (If I remember well)

Here the file.

Thanks and Regards

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 16, 2018, 10:36:59 am
One line of text appears to be in the wrong location.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 16, 2018, 11:29:09 am
One line of text appears to be in the wrong location.


All the lines are in wrong location, sadly the text is problematic.

we have to transform it in somthing else to extract a BB and apply the placement according the CB align properties.

So this has to be discussed on how to tranform the text the FC annotations don't have a BB "property"

Regards

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 16, 2018, 12:02:50 pm
HI Carlo
I've just got a chance to try out the file.
I noticed two things:
1. the cb file doesn't load up with .98 ok with ver 1.
2. the text that's moved over has it's Alignment property set to center rather than left justified like the others.

Currently I'm swapping files between CB and Freecad using .dxf,.stl's and step files, which works pretty well
most of the time and I"ve used this method extensively for my turret project, so I'm very familiar with those files
and how they work with both programs, so tomorrow I've got a bit of spare time and will use one of those files as they are complex and give your app a good workout.
 
Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: BR52 on October 16, 2018, 17:50:15 pm
Hi Carlo

Bug when creating a circle with the center (0,0,0).

See the attached file, the entity Circle ID = 32 in cambam.
Move the entity to another layer and put in any position.

   Repeat in other positions, see the results.

   Armando


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 17, 2018, 00:06:03 am
HI Armando
I downloaded the file and followed the instructions, and the circle seems ok for position and size.
What happened for you.
 I'm using  Win7 32 bit Freecad 0.17
Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: BR52 on October 17, 2018, 03:29:19 am
Hi Dave

In your image does not appear Circle ID=32.

See my image does not also appear the circle in the middle of Freecad.
Compare with CamBam.

I'm using  Win10 64bit with Freecad 0.18 Qt 4.8.7 Python 2.7.14 --> PySide

   Armando


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 17, 2018, 10:45:11 am
Strangely enough another quirk on the xml format, che c property is not in the XML if it is (0,0,0), some check I will add a deafult 0,0,0 if none center is found on the XML of the circle entity.

EDIT: Added some control over the 'c' XML-attribute of the Circle

Thanks

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: Dragonfly on October 17, 2018, 12:28:17 pm
This seems to be in unison with the missing Z values of points when Z=0.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: BR52 on October 17, 2018, 15:15:23 pm

With OneCAM-beta_5 version It was very good, excellent now!
Good job, this tool will help a lot on CamBam.

CamBam and Freecad.

   Armando



Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 18, 2018, 10:03:13 am

With OneCAM-beta_5 version It was very good, excellent now!
Good job, this tool will help a lot on CamBam.

CamBam and Freecad.

   Armando

Thanks, any hints for the text translation? now i have used annotations in FreeCAD but they are not scaled, using the 

shapestring  in the creation routine, we have to resolve the differences between Linux and Windows in fonts, maybe i will try to extract a "default font " from the running freecad to extract a path that could be reused to print at least the text and leave the user to cope with the proper font after the FreeCAD objects creation.

Another problem is the "metrics" used by CamBam and FreeCAD as in FreeCAD the font is specified in FreeCAD units, in CamBam, i suppose it's the same, but even in CamBam you have to adjust the size to obtain a desired height.

For the Placement, when in FreeCAD the object is created, I hope it will be possible to obtain the BB and translate the starting point according to the CamBam alignment properties (Vertical and Horizonthal)

Code:
Draft.makeShapeString("This is a sample text",
"/usr/share/fonts/truetype/msttcorefonts/Arial.ttf",
200.0,10)

This seems to be in unison with the missing Z values of points when Z=0.

The missing z=0 is only in the CB Pointlist:


Code:
<points id="3">
          <ModificationCount>44</ModificationCount>
          <mat m="Identity" />
          <pts>
            <p>33,29</p>
            <p>44,16</p>
            <p>48,27</p>
            <p>36,32</p>
            <p>44,40</p>
            <p>45,28</p>
            <p>54,20</p>
            <p>58,26</p>
            <p>56,35</p>
            <p>63,28</p>
          </pts>
        </points>



Probably beacuse it utilize the Point2F

In polylines and even in rectangles it specifies a Point3F so


Code:
<pline id="1" Closed="true">
          <ModificationCount>46</ModificationCount>
          <mat m="Identity" />
          <pts>
            <p>29,68,0</p>
            <p>42,52,0</p>
            <p>117,44,0</p>
            <p>111,68,0</p>
          </pts>
        </pline>


this is a rectangle with rounded corners, note the bulge parameters in the pline that define the contour

Code:
<rect id="4" Closed="true" p="137,67,0" w="52" h="21" radius="2">
          <ModificationCount>47</ModificationCount>
          <Tag>With corner radius</Tag>
          <mat m="Identity" />
          <pts>
            <p>139,67,0</p>
            <p b="0.41421356237309503">187,67,0</p>
            <p>189,69,0</p>
            <p b="0.41421356237309503">189,86,0</p>
            <p>187,88,0</p>
            <p b="0.41421356237309503">139,88,0</p>
            <p>137,86,0</p>
            <p b="0.41421356237309503">137,69,0</p>
          </pts>
        </rect>



Regards


Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 18, 2018, 14:03:32 pm
In the file, OCB_Gui.py , I would get rid of the p2 code and make it like this.

Code:

# it's around line 1067

p1 = item.get('p1').split(',')
        
px = float(p1[0])
py = float(p1[1])
pz = float(p1[2])



Then in FreeCAD, the text has to set to, "Display Model = World" , instead of  "Display Model = Screen"

This seems to work okay for me, try the attached file before and after those changes.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 19, 2018, 05:46:50 am
HI Carlo

I just used the OneCam workbench today to modify one piece of an already completed File.
What I found was that all of the CB files geometry was imported again, which got a bit messy.

What I have been doing, is using the "Export Selection To" function in CB and making a small .dxf and then importing that into Freecad to make small corrections to an existing file.

I don't think you can do this with your App, But I think it would be useful if you could set it to only import Visable layers as an Option.

This way I could put the Geometry to be modified (it may be only a small change in a realy big file), on a seperate layer and just export that layer.

Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 19, 2018, 07:47:47 am
dave benson

If I guess right you want to import only one entity, this could be done with the green + button on the OneCAM toolbar.

If you want to import only one layer, maybe a button could be added to select all the entities in a layer and import only those.

If I'm not guessing right, excuse me and try to explain me whta you want to be achieved.

Regards

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 19, 2018, 10:08:03 am
HI Carlo

I've had a bit of time to think about this, and what I realy wanted to do was multi-select items
in the panel (shift click + CNTRL click) to select the items that I want to add to the Freecad document.

See the picture, If I could mulit-select select items in this panel and import them just like the way you can mult-iselect items in CB
that would very useful.
I'm starting to use OpemCam with 0.18 now that the path workbench has expanded significantly and 0.17 and 0.18 on windows at least
seem to operate Identically.

Good work Carlo, for we CB'ers who use Freecad this is a worthwhile and handy  workbench.

Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 19, 2018, 11:30:52 am
I have to investigate the Qt control for multiple selection, as the standard settings seems to permit only one selection.

I've expanded the "green +" to permit the import of all the cadobjects if a Layer name is selected, they are imported in FC in a group named CB_Layer-{Name of the Layer}

Added the desidered feature (hope), now you can select the cambam entities and import them in FreeCAD and push the "green +" to import them in a group named  CBselection.

When you select a single CB entity and push the "green +" it will be placed in a group named  CBdefault.

This permit to quickly differentiate between the different functions of the "green +"

This version add also a little modification to the text field as suggested by

...
Then in FreeCAD, the text has to set to, "Display Model = World" , instead of  "Display Model = Screen"
...

As a side note, there were a version OneCAM-beta7 that has some broken identation, it have been online for roughly ten minutes, but this warning is done just in case someone have downloaded it.


Regards

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 19, 2018, 16:35:22 pm
Carlo,

The "world" part is working now but using p2 is putting text in the wrong place.
It also looks like the line of text, "Testo del campo testo  è+è+è+éçéçé" that is centre aligned needs some further attention.

I can't find the exact code but I think something like this should be used for alignment to centre for example;

obj.setAlignment(QtCore.Qt.AlignCenter)


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 20, 2018, 00:51:52 am
HI Carlo
I tried out 0.7a and it works well for me Thank You.
With the Text justification, I came accross this while looking through Stack Overflow.
https://stackoverflow.com/questions/49813012/pyqt4-setalignmentqtcore-qt-aligncenter-works-perfectly-in-linux-but-not-on-m (https://stackoverflow.com/questions/49813012/pyqt4-setalignmentqtcore-qt-aligncenter-works-perfectly-in-linux-but-not-on-m)
When I looked at the answer at the bottom of the page (and comparing it VS generated code) for a form, it did make sense.
Hope this helps or at least gives you some clues to chase down.
Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 20, 2018, 11:15:56 am
HI Carlo
I tried out 0.7a and it works well for me Thank You.
With the Text justification, I came accross this while looking through Stack Overflow.
https://stackoverflow.com/questions/49813012/pyqt4-setalignmentqtcore-qt-aligncenter-works-perfectly-in-linux-but-not-on-m (https://stackoverflow.com/questions/49813012/pyqt4-setalignmentqtcore-qt-aligncenter-works-perfectly-in-linux-but-not-on-m)
When I looked at the answer at the bottom of the page (and comparing it VS generated code) for a form, it did make sense.
Hope this helps or at least gives you some clues to chase down.
Dave
Carlo,

The "world" part is working now but using p2 is putting text in the wrong place.
It also looks like the line of text, "Testo del campo testo  è+è+è+éçéçé" that is centre aligned needs some further attention.

I can't find the exact code but I think something like this should be used for alignment to centre for example;

obj.setAlignment(QtCore.Qt.AlignCenter)


This work for qt widgets, the text is nt a qtwidget, but a FreeCAD entity (from Draft Workbench is an annotation).

The problem is to extract the boundig box of the text and then apply the CamBam TextAlign (Hor and Vert) properties relative to the position point.

The porperty in CB are the position point and the Alignement, so If I place a texo say 100,100 and then i set the position to TextAlign Vert Center i have thi text centered vertically around Y100, the same thing with horizonthal.

In FreeCAD the position is the Bottom Left corner and to calculate the proper position according to the CB properties of Alignement we have to calculate the BB and move the start position accordingly, plus maybe set two properties in the FC created object holding the textalignement properties if we would in future retranslate to CB (Another big work wold be the interoperability between the two program) this could be achieved as at a first glance the FC "object" properties could be expanded by the user and which permit to hold those properties that are difficult to retain across the CB -> FC translation.

The text as annotations retains the text content, but the font is another problem, as the font has to be set in different ways according to the platform (Windows and Linux have different mammers to manage fonts).

The text as Shapestring would be more appealing, but the font problems are worse as in the creation procedure you have to specify a font (and the shapes seems to be created as "solids" with 0 height) so it will be possible to extract the Bounding Box and retain a more similar placement as in CB.

If the test is used for engraving the problem is maybe worse, but as I haven't used the engraving MOP of CB i don't know how it is treated (maybe it is converted to polyline prior to the engraving MOP).

These  are the problems in Text translation, some hints are welcomed and appreciated.

Regards

Carlo D. 


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 20, 2018, 11:25:42 am
Carlo,

I thought the text might be how you described it. Getting the bounding box sounds like the way forward.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 20, 2018, 11:53:39 am
Carlo,

I thought the text might be how you described it. Getting the bounding box sounds like the way forward.

Studying more i have found that the Annotation is a mere representation, not an object and diepends on the "view", so the Camera and zoom are taken in account, and you have to manage to use at low level the "rendering engine" of FreeCAD.

https://forum.freecadweb.org/viewtopic.php?t=22782 (https://forum.freecadweb.org/viewtopic.php?t=22782)

The text annotation has a nabber to psecify the horizonthal justification so at least one of the textalign property could be honoured in thetranslation.

Using the SapeString and find a way to cope with the need to specify a font, (maybe the font you specified in the CB is not present, so using a fallback font could be suboptimal but a viable solution).


What do you think about it.

Regards

Carlo D.
 


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 23, 2018, 16:09:46 pm
Some work has be done on the workbench, but it is not ready for publiching, in some spare time (from family duty) I've started to experiment with FreeCAD 0.18 and so with Python3 and Qt5 (as the development version is using these two), so I've started to iron out some incompatibilities, mostly in the "debug" part with the print that become print() "function", luckyly it is backward-compatible with python 2.7 so for now a single version could be retained.

But it is not an esay and plain work as at least for Qt4 and Qt5 the difference is little but it is present.

Only to inform about the progress, in the meantime, I've gave a little look at the Path Workbench (the CAM part of FreeCAD) and at a first glance it seems a little involuted comparing to the "CamBam" way, but not too difficult, so one more long term goal is to port the CamBam tooltable to FreeCAD, that has also a nice Simulation part.

I've investigated the horizonthal placement of the text and seems that this could be honoured using a visualization porperty (ViewObject if i didn't go wrong)

Regards

Carlo D.



Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 25, 2018, 13:16:09 pm
HI Carlo

I had a little time on the weekend to look at the Path workbench, and it uses a different approach to CB, being
truly 3D.
I made a Mach3 PP for it (most people have been advised to use the Linuxcnc one) which will work
but I've added a few things to make it resemble my CB PP.

Still more to learn but I'm enjoying it, I like the Simulator and will do some tests to see if it can do things like
represent G83 canned cycles as Camotics can not do this yet.

The tool Libs in Freecad Path look like a subset of the CB ones.
Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 25, 2018, 15:47:31 pm
In the Meantime, I'm starting to test it on 0.18

First iteration is beta_8, no new features, only added some code to detect the Qt5 and rewrite some code to be compatible to Python3.

It is not a great improvement, but seem to work on my shiny new 0.18 AppImage I've just downloaded.


Beta_9 is a more modified version with some code adaptation for Pyside2 (a little trick to prepare for the transition)

plus the Text object now honour the horizonthal position using the Justification parameter of Qt (The text is an Annotation)

the "p2" parameter is fixed now (I've interpreted wrong his meaning)

So here the file

Regards

Carlo D.


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 25, 2018, 23:25:09 pm
HI Carlo
Ver 9 reports an Indentation error for me.
Dave


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 28, 2018, 10:38:51 am
HI Carlo
Ver 9 reports an Indentation error for me.
Dave

Sorry, in the process of saving, i wrongly hit the spacebar (I suppose).

Here the ver 9a with the typo fixed


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: EddyCurrent on October 28, 2018, 11:16:56 am
Have you tried importing a cb file that uses inches ?


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 28, 2018, 22:28:32 pm
HI Carlo

Thanks, works fine now. I read recently that the Python crowd are moving away from the Tab Delimited formatting
in favor of space Delimiting.

I've had a bit more time with the Path Workbench and have discovered that once you get used to it, it's pretty easy to use (I like working with the 3D model)  where a fair bit of the work is done for you Automatically (in applying the Mops).

Work holding tabs are applied separately in the Dress-up's where there are also things like Drag knife Dress-up features as well. Nice!

I am using the Latest Nightly Build 0.18 (couple of days ago).
I have loaded up Imperial Files (Changed my Freecad  Prefs first) and they seem OK.

Dave
 


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: dave benson on October 29, 2018, 07:08:34 am
Hi All

Just added the full complement of Mop's to my Freecad Toolbar, there are heaps of mops that are not shown at startup
and may be missed, one of particular interest is Full adaptive tool path, as well as clamp and fixture hopping just to name a few. It'll probably take me a few weeks to get around to testing then all out. feel like a kid at Xmas ;D
The G83's seem to be fine, as well as G41\G42 offsets, Axis mapping ect ect.
Dave
edit forgot pic:


Title: Re: FreeCAD WorkBench to import CBfiles
Post by: onekk on October 29, 2018, 10:09:28 am
Yes it seems that FreeCAD Path Workbench is growing rapidily.

I'm planning to investigate some features of FreeCAD, but as it is more geared towards 3D working, and my machine and my "work" is more 2.5 D (cutting plywood sheets) CamBam has some "point" over FreeCAD.

But it depends on how the CamBam development will be in the future, as the FreeCAD community is more responsive to suggestion than CamBam developer(s) maybe even the Path Workbench will evolve in a manner that will be so intuitive as CamBam in 2.5D work.

In the meantime, i will investigate more areas for OneCAM (let me call in this manner)

1) finish the import of the CB entities in a decent manner so the work to obtain some GCode in FreeCAD will be nmore easy (maybe trying to reproduce the MOPs parts in FreeCAD)

2) working on some little "export to CamBam" feature to obtain a loadable CB file

I'm investigating the "inner work" of FC shapes as at a first glance it will be possible to pass some "custom  parameteres" to the FC shapes to hold some important information that permit the "reverse work" of exporting in CamBam.

3) a way to "import" the CB Tool Table between in FC.

These are the main area of future development, maybe not very near future, maybe some weeks or even some months, as developing in FC (and having in the IDE the python "classes and parameters" visibility is not very easy)

But the codebase is opens so some investigation is possible in every corner of the software.

Regards

Carlo D.