XUL GUI Spec?

The Blender GUI is fairly unique, of course, but I’m wondering just how unique it really is at the foundation.

Assuming that I can read and interpret a XUL user interface specification, would it even be possible in principle to implement it in Blender’s UI?

Perhaps more to the point, would XUL be able to express the UI design that Blender currently has?

Are there other UI spec languages that could, if XUL can’t?

Being able to specify the GUI in a “standard” language like XUL would be very helpful for a project I’m working on, as it would make the choice of UI engine neutral, allowing a Blender solution to be used, but not requiring it for other client software.

But on the other hand, if Blender’s UI must be “crippled” in order to conform to a XUL spec, then it throws away much of the reason for using Blender’s UI in the first place.

If this sounds a bit vague, I’m sorry, the overall concept is still a bit fuzzy for me (too many variables as yet). I’m trying to understand the problem better.

XUL is a very nifty tool, but as far as I know, it strongly relies on Javascript, doesn’t it? Anyway, if it didn’t, or if language ties were avoided, I’m sure it’s possible to make this happen.

Blender API exposes very low-level widget creation functions; a script could be made that reads XML description, computes the layout and then calls the widget creation functions. All of that is doable in pure Python (with appropriate modules present); it’s a matter of someone developing it :). Also, Blender GUI doesn’t have all the primitives required for the XUL widget set; some would have to be “faked” using buttons and maybe direct GL calls.

Anyway, I am not exactly sure why you want to do this - there are already some simple libraries to lay out Blender widgets in Python plugins. If you want to use Blender just for the GUI capabilities, I would again suggest some other libraries, like WxWidgets.

I think Mozilla’s implementation does, but my impression is that there are several implementations. I don’t know if Javascript has to figure in or not.

Anyway, I am not exactly sure why you want to do this - there are already some simple libraries to lay out Blender widgets in Python plugins. If you want to use Blender just for the GUI capabilities, I would again suggest some other libraries, like WxWidgets.

Well I’m not sure that I do want to do this.

What I’m looking at is that there is a real need for a true free-software 3D mechanical CAD/CAM solution. If I look at what the nearest thing to that is, Blender certainly stands out.

But Blender is not a CAD program. There is a need to represent a lot of model data in ways that Blender is not designed to do – to hold on to meta-data (such as materials and tolerances), and to use a variety of CAD standard model representations, and there is a need for a CAD-oriented drawing/modelling interface.

However, despite these “model” deficiencies, Blender has a great “view” and a great “controller”. Factoring them out into a true MVC model would allow the model component to be swapped, and Blender’s scripting would allow the controller to be designed for CAD applications. Blender’s source code does not seem to be set up to make that easy, though. Certainly my ideal concept of building a CAD system using Python and the interpreter built into Blender seems not to be feasible.

Having used Blender’s GUI, I’ve been very impressed that it is the right sort of design for a CAD system, though. But them I’m forced to wonder why that is , exactly. Is the Blender GUI just a guideline, to be emulated in some other GUI toolkit? In other words, is it the primitive structure of Blender’s GUI that makes it good, or is it just a good layout of otherwise common widgets? If the latter, then maybe Blender isn’t essential, but also maybe Blender could be one of several choices for widget toolkit. If there’s meant to be several,then working from a GUI spec language like XUL seems like a good idea (although ironically it also arises from a desire for a separable GUI, unlike Blender’s).

The view seems a bit less serious, since there are other 3D rendering libraries that could be used. Still, the Blender interface for editing is awfully good, and that’s highly integrated with both view and controller.

did you look at BlenderCAD etc? that was a fork of Blender for CAD, right? and there is also some CAD script for Blender, no?

regarding the Blender data model, i’ve started an attempt to make Blender use Python data - see http://mediawiki.blender.org/index.php/BlenderDev/PythonBlender … that data model could probably be made quite a bit more flexible than the current one, which is pretty slick too though.

also there seems to be http://www.pythoncad.org/ - did not looked closely but seemed ok. if we manage to get also Blender to use a Python base then these two apps would probably be quite easy to get to work together…

but surely also otherwise the modularization, like separating the GUI, would be good in many ways … it is just difficult to achieve, and does not help in the more immediate goals we have.

~Toni

Thank you, somehow I missed “BlenderCAD” even thought it’s such an obvious name, I thought of using it myself at one point. Looks pretty early though – it could be I need to work within that project. I’ll have to see.

Unfortunately people mean many different things when they say “CAD”, so I have to look very closely to see if a given project actually has similar goals. I’m wanting to find or create something that could actually take the place of commercial engineering CAD systems, and then go beyond, by tackling the problems of free internet collaboration tools that the free software development community has proved itself so good at solving (indeed, I think the problem will be almost solved when the application is factored properly – since collaboration tools already exist).

regarding the Blender data model, i’ve started an attempt to make Blender use Python data - see http://mediawiki.blender.org/index.php/BlenderDev/PythonBlender … that data model could probably be made quite a bit more flexible than the current one, which is pretty slick too though.

Now that sounds exciting. When I started looking into this, I found out about how Blender objects are really C structs. One obvious way to hack Blender into an MVC model, is to actually use a MMVC model, in which there is a CAD model M which is mapped to a Blender representation model, M that interacts within the program (with which Blender’s View and Controller are integrated). That would work fine for me if it could be made to work.

The problem is that M* will be quite different from M, and I doubt that full round-trip conversion can be guaranteed. That means that all the CAD controls have to work directly on the M* model, so that the CAD model is always driving the Blender model. In order to take advantage of Blender’s interface, though, I’d want to map transformation commands to the CAD model, so I’d want to use objects within the Blender model (M) that had callbacks so they could report how they were being transformed. Then the M* model could be updated.

One nice thing about this, is that the Blender model, being a “rendering” of the CAD model (M* -> M) would automatically provide support for creating art from CAD models, which is a nice feature (in professional CAD systems, you usually have to do the CAD work, export to a rendering tool like Blender, in order to make artistic ray tracings from the model, for example).

The problem is that you’d need a Blender object that did a callback whenever it was transformed within Blender. I’m wondering if that’s something you have (or could easily) do with your PythonBlender?

also there seems to be http://www.pythoncad.org/ - did not looked closely but seemed ok. if we manage to get also Blender to use a Python base then these two apps would probably be quite easy to get to work together…

PythonCAD is a great, but still quite immature 2D CAD system. Indeed, I would hope to use it as a 2D module. It’s the 3D module that I still consider missing at this point. (There is also QCAD which is more mature and has a better GUI, but I’m more inclined to bring PythonCAD’s GUI up to spec – I believe Python has real potential because it’s the kind of programming language that engineers can handle as opposed to career programmers – free software usually must be maintainable by its users to succeed).

There is also the point of interoperability. In order to be used professionally, a free software 3D mechanical CAD system will need to have file-level (which implies model-level) compatibility with proprietary industry-leading CAD systems like AutoCAD. I had been thinking to use the ISO “STEP” (or ANSI “PDES”) standard for that, but I’m distressed to find that these aren’t really open standards, so I’m having to reconsider that idea.

As you know there are many ways to implement a 3D model of a given form. Blender can get away with a fairly sparse set of model systems, and can even do shapes approximately. But whereas a sufficiently large-order polygon can be considered a circle in the Blender M model, the CAD M* model has to know it’s really meant to be a circle (for example). Hence M* is going to be a much richer collection of modelling methods in general. One way to get that is to try to support the set of representation models in STEP.

but surely also otherwise the modularization, like separating the GUI, would be good in many ways … it is just difficult to achieve, and does not help in the more immediate goals we have.

Yes it would, and yet I fully understand this is not what the Blender team wants to focus on. Blender is a terrific artistic modelling and animation system, which is what it should remain. The question is whether it’s possible to leverage that development to provide CAD too.

I think the M* -> M mapping and M -> M* callback concept would provide a means of doing that with a fairly small hack. Unfortunately, while I’m willing to put some effort into Python-level development, I’m pretty rusty in C, and I really don’t work on C projects anymore. OTOH, there do seem to be a number of people interested in this kind of functionality, so I’m trying to send out some feelers and find out what kind of design could get done.

I will take this up with the BlenderCAD folks, too.

Thanks a lot, Toni.

BlenderCAD is defunct and made almost no progress,

they are all doing makehuman right now.

LetterRip

Terry,

there are a number of users who would find XUL based (or other editable layout description) very useful, in particular the ability to easily specify custom button, menu layouts, and keybindings. Work on the event system refactor is planned by lukep which is also needed for some of the above, so I’d recommend contacting him and explaining your plans and see what work could be done in parallel.

Here is file format information on all of the important CAD formats,

http://mediawiki.blender.org/index.php/File_format_list

If you need more information on a particular format, I’d be happy to research it for you although with the libraries and source code I listed there you should have close to the full spec on all of the important CAD formats (the most complete library is GPL incompatible, so would need to be done as a seperate download with a python script if you wanted to use it as a plugin).

LetterRip

TerryH,

also have a look at BRL-CAD, which is a Constructive Solid Geometry/BREP Modeller under the GPL which is maintained by the Army Research Laboratory.

You can probably use it as part of the back end (recently has been ported to windows also but I don’t think the code is in the tree yet). Talk to twingy on IRC (#blendercoders) who is one of its developers, he maintains the raytracer for BRL-CAD.

Also we recently had Nurbana integrated into Blender which will likely be merged into the main tree before 2.40. So improving the interface to that code would also be an option.

So, we could have 2d via pythonCAD, CSG via brl-cad; and Nurbs via nurbana. There are already mature libraries for handling the important supported formats.

to hold on to meta-data (such as materials and tolerances), and to use a variety of CAD standard model representations, and there is a need for a CAD-oriented drawing/modelling interface.

Generic properties are going to be added to Blender so you could handle store type of information. Search the Blender Dev list for the wikipage discussing them.

LetterRip

I’m guessing you’re referring to OpenCascade, which is the only STEP library I’ve found. It has a really irritating license, because they insisted on sticking a talkback clause in there. Had they not done that one stupid thing, the whole thing would be distributable through free software channels.

Why do people do these things? What would it have cost them to make that a request instead of a legal requirement? Sheesh.

So I had seriously considered that OpenCascade is going to have to be replaced. What a waste.

From mailing list postings, BRL - CAD has some step tools

Efforts have been under way towards a new geometry converter for full
AP 203 ISO 10303 STEP support. We’ve have a functioning Express parser
courtesy of the past efforts of friends at NASA and considerable
updates/fixes by narnia (irc) to bring the parser up to date with the
current STEP specifications. We’ll hopefully be able to polish up the
parser and begin work on the mappings from .step to BRL-CAD’s .g format
in one or two iterations. Any help is appreciated, the step
specification support is one of the most complex to implement to date.

that was posted in April, so perhaps some progress has been made,

LetterRip

A reason why XUL might become more important for Blender is that FireFox from version 1.9 will support Python (with XUL) next to JavaScript. It would maybe not be a bad idea if the Blender (UI & events) developpers would collaborate together with FireFox.

For those who never heard about Firefox 1.9, check the following urls.
It looks very promising:

  1. http://wiki.mozilla.org/Roadmap_Scratchpad#Python_for_XUL

Python for XUL

Significant potential contributors in both the Python and XUL
application development communities have long wanted access to Python’s
set of libraries and its capabilities as an application development
language. So in addition to JavaScript, which is the default web and
XUL scripting language, we plan to extend the reach of Gecko and XUL to
the Python world.

  1. http://weblogs.mozillazine.org/roadmap/archives/008865.html

Given evolving JS, why Python? Simple: different programming languages,
of different ages, have their strengths, and one of the greatest
strength of any solid language is its community. We want to support
Python as well as JS for XUL scripting in order to engage a large,
creative community of hackers that is mostly disjoint from the
web-standards-savvy XUL hackers who are already engaged with Mozilla
and Firefox.

Stani

http://pythonide.stani.be/manual/html/manual.html

hm. i don’t quite see how Blender could use Mozilla technologies, but of course it is great that they will be able to inter/co-operate well.

interesting news in any case.

~Toni