CamBam
News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 23, 2019, 12:00:44 pm


Login with username, password and session length


Pages: 1 2 [3] 4
  Print  
Author Topic: FreeCAD WorkBench to import CBfiles  (Read 6023 times)
onekk
Wookie
****
Offline Offline

Posts: 452


View Profile
« Reply #30 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.

* OneCAM-beta_5.zip (31.56 KB - downloaded 48 times.)
« Last Edit: October 17, 2018, 11:02:33 am by onekk » Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
Dragonfly
CNC Jedi
*****
Offline Offline

Posts: 2116



View Profile
« Reply #31 on: October 17, 2018, 12:28:17 pm »

This seems to be in unison with the missing Z values of points when Z=0.
Logged
BR52
Wookie
****
Offline Offline

Posts: 329



View Profile
« Reply #32 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

« Last Edit: October 17, 2018, 15:18:47 pm by BR52 » Logged
onekk
Wookie
****
Offline Offline

Posts: 452


View Profile
« Reply #33 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.
Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3965



View Profile
« Reply #34 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.

* Text_1.cb (2.71 KB - downloaded 47 times.)

* fc2.jpg (86.13 KB, 1000x474 - viewed 87 times.)
« Last Edit: October 18, 2018, 14:08:11 pm by EddyCurrent » Logged

Made in England
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1113


View Profile
« Reply #35 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


* Capstan lever arm only needs to be modified.PNG (167.24 KB, 839x542 - viewed 81 times.)

* Only Modifing Capstan Lever Arm.PNG (39.8 KB, 638x414 - viewed 83 times.)
Logged
onekk
Wookie
****
Offline Offline

Posts: 452


View Profile
« Reply #36 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.
Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1113


View Profile
« Reply #37 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


* Multiselect would be nice in the panel.PNG (30.39 KB, 881x504 - viewed 87 times.)
Logged
onekk
Wookie
****
Offline Offline

Posts: 452


View Profile
« Reply #38 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.

* OneCAM-beta_7a.zip (32 KB - downloaded 46 times.)
« Last Edit: October 19, 2018, 16:08:58 pm by onekk » Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3965



View Profile
« Reply #39 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)
« Last Edit: October 19, 2018, 20:51:15 pm by EddyCurrent » Logged

Made in England
dave benson
CNC Jedi
*****
Offline Offline

Posts: 1113


View Profile
« Reply #40 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
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
Logged
onekk
Wookie
****
Offline Offline

Posts: 452


View Profile
« Reply #41 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
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. 
Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3965



View Profile
« Reply #42 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.
Logged

Made in England
onekk
Wookie
****
Offline Offline

Posts: 452


View Profile
« Reply #43 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

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

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
onekk
Wookie
****
Offline Offline

Posts: 452


View Profile
« Reply #44 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.

Logged

Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam
Pages: 1 2 [3] 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.175 seconds with 19 queries.

Copyright © 2018 HexRay Ltd. | Sitemap