SQL Reporting Workbench for FreeCAD

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: SQL Reporting Workbench for FreeCAD

Post by mario52 »

hi
HolgerL wrote: Fri Dec 06, 2019 8:01 am - removed the mm and make the fields number
- filtered Length,Width,Height for 16mm entries, because these are the furniture plates. (40mm are the sidewalls..) and gave them a 4. filter attribute
- for all these furniture entries I simply calculated the volume and devided by 16 to get the total plate area. done
try also this macro, you split like you want Macro_FCTreeView Image but FreeCAD version 0.17 no yet upgraded

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
dcapeletti
Posts: 504
Joined: Wed Jul 23, 2014 2:27 pm

Re: SQL Reporting Workbench for FreeCAD

Post by dcapeletti »

furti wrote: Sat Jan 12, 2019 11:02 am Columns
Columns is a comma separated list of properties you want in the result for each object.

* is a special property that returns the whole object instead of a single property. This might be useful when you want to perform certain operations on some objects in python. You can select them with a select statement, and process them afterwards.

When you use a function (Sum, Min, Max, Count) here, only a single row will be returned with the function applied to each object. You can not mix single Properties and functions. But it should be possible to use multiple functions in a single select statement.
Hello, if I add a new property to the object called Provider, can I access it by means of an sql instruction? How can I do it?

Code: Select all

select Provider from document where Name = 'Box'
select Base_Provider from document where Name = 'Box'
None of the above instructions work.

Thanks
User avatar
furti
Posts: 344
Joined: Mon Nov 27, 2017 5:27 pm

Re: SQL Reporting Workbench for FreeCAD

Post by furti »

You mean the property is called "Provider"?
If so, the first query should work.

What is the problem with the query?
User avatar
dcapeletti
Posts: 504
Joined: Wed Jul 23, 2014 2:27 pm

Re: SQL Reporting Workbench for FreeCAD

Post by dcapeletti »

furti wrote: Mon Feb 17, 2020 6:01 am You mean the property is called "Provider"?
If so, the first query should work.

What is the problem with the query?
It's a dynamic property that I add to the object myself.
Attached is a sample video https://www.youtube.com/watch?v=g3Bs_jz ... e=youtu.be

The first query does not throw an error but no result is shown, in the second query, the next error is thrown.

Code: Select all

ERROR:root:
Traceback (most recent call last):
  File "/home/dcapeletti/.FreeCAD/Mod/Reporting/report.py", line 352, in __init__
    self.statement = SQL_PARSER.parse(plainTextStatement)
  File "/home/dcapeletti/.FreeCAD/Mod/Reporting/sql/sql_parser.py", line 1149, in parse
    sqlStatement = sql_grammar.parse(sqlString, actions=ParserActions())
  File "/home/dcapeletti/.FreeCAD/Mod/Reporting/sql/sql_grammar.py", line 1958, in parse
    return parser.parse()
  File "/home/dcapeletti/.FreeCAD/Mod/Reporting/sql/sql_grammar.py", line 1942, in parse
    raise ParseError(format_error(self._input, self._failure, self._expected))
  File "<string>", line None
sql.sql_grammar.ParseError: Line 1: expected [a-zA-Z0-9\.], [ \t\r\n], [ \t\r\n], ","
Select Label, Base_Provider from document where Name = 'Box'
                  ^
But as shown in the spreadsheet, through Box.Base_Provider I can recover the data without any problem.

Greetings
User avatar
furti
Posts: 344
Joined: Mon Nov 27, 2017 5:27 pm

Re: SQL Reporting Workbench for FreeCAD

Post by furti »

Now I can see what is wrong here. The character _ is not allowed in Property names right now. I created a Issue for this. https://github.com/furti/FreeCAD-Reporting/issues/27

Is it possible that you rename the Property to something Alphanumeric like "BaseProvider" instead of "Base_Provider"?
User avatar
dcapeletti
Posts: 504
Joined: Wed Jul 23, 2014 2:27 pm

Re: SQL Reporting Workbench for FreeCAD

Post by dcapeletti »

furti wrote: Tue Feb 18, 2020 9:07 am Now I can see what is wrong here. The character _ is not allowed in Property names right now. I created a Issue for this. https://github.com/furti/FreeCAD-Reporting/issues/27

Is it possible that you rename the Property to something Alphanumeric like "BaseProvider" instead of "Base_Provider"?
Hello, the query works correctly if I create the property but do not add it to any group, as shown in the image. That way if you can access it directly with Provider, but if I add it to a group, FreeCAD adds the group name separated by _.
Attachments
Group property.png
Group property.png (16.37 KiB) Viewed 2536 times
User avatar
dcapeletti
Posts: 504
Joined: Wed Jul 23, 2014 2:27 pm

Re: SQL Reporting Workbench for FreeCAD

Post by dcapeletti »

I think this project is very powerful when it comes to creating reports and not only that, but using object manipulation instructions via the freecad API using SQL directly. :)
fredericleuba
Posts: 13
Joined: Thu Mar 19, 2020 3:56 pm

Re: SQL Reporting Workbench for FreeCAD

Post by fredericleuba »

Hello,

Great workbench :-) Thanks.

But it seems that something is missing somehow.
It would be absolutely great to add the following (illustration with picture bellow).

I have a query that gets all objects and get a property from them.
It finds original objets and their links.

But I have links to more complex structures than simple object.
In particular, links to Assembly3 organisation, which itself contains a subtree of groups and objects.
I would expect the SQL-like query to also follow these Assembly3 links, and scan deeper inside.
Indeed, I would expect the query to return 10 links to the part "80x40L-4N 100".

I hope you understand.
I may help, as I'm a developer. But my free time is super limited.

Image
Attachments
FreeCAD tree with deep links
FreeCAD tree with deep links
freecad_deep_query.png (488.44 KiB) Viewed 1971 times
stefano1
Posts: 21
Joined: Thu May 07, 2020 3:15 pm

Re: SQL Reporting Workbench for FreeCAD

Post by stefano1 »

Hi!
I've just tried this WB..exactly what I was looking for :D but..

this works:
Select Label,Length from document where IfcType = 'Pipe Segment' and Description = 'whatever' and Diameter = 16;

this, doesn't:
Select Label,Length from document where IfcType = 'Pipe Segment' and Description = 'whatever' and Diameter = 1.6; #(or 1,6)

File "/home/stefano/.local/share/FreeCAD/Mod/Reporting/sql/sql_grammar.py", line 1990, in parse
raise ParseError(format_error(self._input, self._failure, self._expected))
sql.sql_grammar.ParseError: Line 1: expected [0-9], [ \t\r\n], [ \t\r\n], ";"
Select Label,Length from document where IfcType = 'Pipe Segment' and Description = 'multistrato' and Diameter = 1.6
^

- I guess Diameter is defined as decimal so what am I doing wrong? I'm using the weekly build 35759.
- how can I be aware of the consistency, unit-wise?

cheers!
stefano
Post Reply