[ArchWall - PR Merged] Auto-creating ArchSketch

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [ArchWall] Auto-creating ArchSketch

Post by paullee »

In fact, it is lucky we have advanced coder in addition to Yorik, hopefully there would be more :)

And more contributors maybe on several aspects are welcome :-
  1. Roadmap masterminds
  2. Features / bug reports
  3. Tests
  4. Documentation / Wiki / Release notes
  5. Publicity
Any other ideas? (somehow off-topic :lol: )
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [ArchWall] Auto-creating ArchSketch

Post by paullee »

paullee wrote: Sun Sep 25, 2022 12:22 am Before any further features/improvement are suggested, may try do a PR to see if the core developers accept it :)
PR submitted :D

https://github.com/FreeCAD/FreeCAD/pull/7526
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [ArchWall - PR Submitted] Auto-creating ArchSketch

Post by yorik »

Ok looks good..
BTW what happens if you open a model containing an Arch Sketch on a computer that has ArchSketch not installed? Have you tested?
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [ArchWall - PR Submitted] Auto-creating ArchSketch

Post by paullee »

yorik wrote: Tue Sep 27, 2022 8:50 am Ok looks good..
BTW what happens if you open a model containing an Arch Sketch on a computer that has ArchSketch not installed? Have you tested?
Yes, tested, the features like automatic attachment would not work. If an user save the model file again without the SketchArch add-on loaded, the model would not work even the file is subsequently opened with SketchArch add-on loaded though.

Same behaviour as all other objects e.g. Arch Objects right ?
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [ArchWall - PR Submitted] Auto-creating ArchSketch

Post by paullee »

Yorik commented on the code; revised code attached, seems working here, any volunteers to help testing ?

Thanks :D

ArchWall.py
(80.43 KiB) Downloaded 45 times
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [ArchWall - PR Submitted] Auto-creating ArchSketch

Post by yorik »

paullee wrote: Tue Sep 27, 2022 5:50 pm Same behaviour as all other objects e.g. Arch Objects right ?
Yes, except that since Arch is bundled by default, there is little chance for this to happen.

We could do something like the Rebar addon: It doesn't provide its own FreeCAD objects, rather it plugs on the existing Arch Rebar object. As a result, files worked with the Rebar addon are still openable on "vanilla" FreeCAD (with no addons), only they don't have the logic to recompute if some property changes.

Maybe that would be doable with ArchSketch? Like, use a standard sketch object but add properties/logic to it?
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [ArchWall - PR Submitted] Auto-creating ArchSketch

Post by paullee »

yorik wrote: Wed Sep 28, 2022 2:10 pm Yes, except that since Arch is bundled by default, there is little chance for this to happen.

We could do something like the Rebar addon: It doesn't provide its own FreeCAD objects, rather it plugs on the existing Arch Rebar object. As a result, files worked with the Rebar addon are still openable on "vanilla" FreeCAD (with no addons), only they don't have the logic to recompute if some property changes.

Maybe that would be doable with ArchSketch? Like, use a standard sketch object but add properties/logic to it?

I see the problem you point out. ArchSketch is Sketcher::SketchObjectPython object, seem nothing similar at the moment, see below codes on its creation :-
https://github.com/paullee0/FreeCAD_Ske ... 1514-L1521


The codes of the ArchSketch class are :-
https://github.com/paullee0/FreeCAD_Ske ... py#L51-L65


Seems not the same way as rebar.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [ArchWall - PR Submitted] Auto-creating ArchSketch

Post by yorik »

See how it works in Arch/Rebar:
This is the built-in Arch Rebar object. It does nothing else that compute a shape based on the underlying sketch. The magic is here: https://github.com/FreeCAD/FreeCAD/blob ... ar.py#L514
The rebars addon is basically a UI addon. It offers dialogs to change the shape of your rebar based on properties.
So basically what the rebar addon does, is change the sketch of a rebar, and store additional properties in the rebar.

So if you open that rebar object on a computer without the addon, you will not be able to edit and recompute the rebar. But you will still be able to open the file without error.

Since your base object is a SketchPython, the same could be done maybe... Maybe we could include it in Arch? If you strip everything you can (UI, etc...) out of it, that might stay in your WB, and only the object definition would go in arch?
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [ArchWall - PR Submitted] Auto-creating ArchSketch

Post by paullee »

Thanks for the detailed explanation. I just got an impression of the way it works reading the codes but not really understand every lines (particularly UI related portion) :) Indeed with limited python knowledge I could only think of having the class definition in Arch, further polluting the built-in WB :lol:

Somewhere in Arch, say Arch.py (?) :-

Code: Select all

class ArchSketchObject:								
    def __init__(self, obj):							
        pass
										
class ArchSketch(ArchSketchObject):						
    def __init__(self, obj):							
        ArchSketchObject.__init__(self, obj)	
        try:
            # External Add-on ArchSketchObject.py
            import ArchSketchObject    
            ArchSketchObject.ArchSketchObject.__init__(self, obj)	
        except:
            pass

    def execute(self, obj):							
        try:
            # External Add-on ArchSketchObject.py
            import ArchSketchObject    
            ArchSketchObject.ArchSketchObject.execute(self, obj)	
        except:
            pass
            
Now, all the methods in the original ArchObjectObject.ArchSketch class become basic functions.

Any better ideas ? Thanks !
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [ArchWall - PR Submitted] Auto-creating ArchSketch

Post by yorik »

That looks basically good to me... That way, files will open without problems, but all the logic stays within Arch Sketch. Maybe instead of pass one could put: FreeCAD.Console.Log(obj.Name+": ArchSketch not found\n")? Not sure if that wouldn't clutter the log, but that's the idea of a log...
Post Reply