Draft Edit improvements

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Draft Edit improvements

Post by yorik »

Amazing job @carlopav !
It's quite exciting to see all the recent developments you guys are doing around arch and draft.
User avatar
regis
Posts: 735
Joined: Sun Jul 12, 2015 8:17 am
Contact:

Re: Draft Edit improvements

Post by regis »

Moult wrote: Wed Feb 20, 2019 8:44 pm @Regis, if you are inclined towards using Linux-like tools, ffmpeg can do what you are asking for:

ffmpeg -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0+0,0 test.mp4
ffmpeg -i test.mp4 -vf scale=480:270 my gif.gif

The first line records your full screen at that resolution (change as necessary) and the second line converts it to a gif at 480x270 resolution.
Thanks a bunch. tested it and it doesn't seem quite as obvious. I ran the command you gave me and there was no way to stop aside from closing the terminal and I couldn't tell where it saved it all.
User avatar
Moult
Posts: 321
Joined: Sat Jan 05, 2019 11:46 am
Contact:

Re: Draft Edit improvements

Post by Moult »

That is correct. It is terminated in a shell usually by ctrl-c. It will save it to the current working directory of the shell. Run "pwd" to see your working directory.
I also blog about 3D rendering, architecture, software and other on thinkMoult.com. RSS / Atom feed available for your convenience.
paullee
Veteran
Posts: 5120
Joined: Wed May 04, 2016 3:58 pm

Re: Draft Edit improvements

Post by paullee »

regis wrote: Sat Feb 23, 2019 1:44 am ... there was no way to stop aside from closing the terminal and I couldn't tell where it saved it all.
:D That's the strength and weakness of command line

I need to write down some commands In a text file as many of them are not used occassionally - otherwise forgot the other day I figured out how to use the command.
User avatar
regis
Posts: 735
Joined: Sun Jul 12, 2015 8:17 am
Contact:

Re: Draft Edit improvements

Post by regis »

paullee wrote: Sat Feb 23, 2019 2:45 am That's the strength and weakness of command line

I need to write down some commands In a text file as many of them are not used occassionally - otherwise forgot the other day I figured out how to use the command.
Yeah not quite practical, I need to search for a different solution. I was back researching how to open an extract an appimage when we had a dedicated forum discussion on it the other day. So yeah...
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Draft Edit improvements

Post by carlopav »

Playing with auto edit set by a selection observer as Yorik suggested. It's already quite fast on my 7 years old cheap laptop, but i was thinking to split the edit command in two so the gui part is activated only if an editpoint is pressed.
nKQjxkpfDP.gif
nKQjxkpfDP.gif (509.04 KiB) Viewed 1898 times
follow my experiments on BIM modelling for architecture design
User avatar
Moult
Posts: 321
Joined: Sat Jan 05, 2019 11:46 am
Contact:

Re: Draft Edit improvements

Post by Moult »

I noticed that when you activate draft edit mode on click, it hides the properties. I suspect that this could be an issue, as most of the time in a BIM model you want to inspect properties by clicking on objects. What do you reckon?
I also blog about 3D rendering, architecture, software and other on thinkMoult.com. RSS / Atom feed available for your convenience.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Draft Edit improvements

Post by carlopav »

Yes, it's just an experiment at the moment, still figuring out how to properly make it work... i just wanted to understand if auto running the command would slow down the drawing process, but doesnt seems so. Anyway i was thinking to refactor the tool a loot... i'll be back to ask for help if i get stucked on some point... and i think i will :)
follow my experiments on BIM modelling for architecture design
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Draft Edit improvements

Post by carlopav »

yorik wrote: Sat Feb 16, 2019 10:08 pm Another idea, if not possible to depend on getObjectsInfo: We do our own routine:
- take the point returned by getObjectInfo, no matter which object was clicked
- take the view direction (ortho cameras) or a vector from the point to the camera position (perspective cameras)
- take another vector from the clicked point to all our edit points
- for each of these, get the angle between it and the view direction vector
- if they are aligned (angle is 0° or 180°), then this edit point is exactly in the line of our clicked point. Then we can consider it was clicked.
Help wanted: i rewrote the "set editpoints trackers" based on a selection observer, so when an object is selected the editpoints trackers are displayed. Also if an object is unselected using Ctrl, the editpoints of that object are removed, etc... So at the moment you can launch every command while points are displayed. if at the end of the command the selection is kept, editpoints are diplayed again, if not, they are removed. Until that point everything works.
Now i'd like to proceed converting the rest of the old edit tool to be activated when a editpoint is clicked, displaying the editui and modifying the object. Do you think that could be a good job or am i going to the wrong path? also i have no idea on how to implement your suggestion. Any code to inspire to? thx.
niN7Rvfwn9.gif
niN7Rvfwn9.gif (247.84 KiB) Viewed 1873 times

Code: Select all

class autoEditObserver:

    def __init__(self):
        self.trackers = []
        self.editpoints = []

    def addSelection(self, document, object, element, position):
        """Add single object to selection. Usually gets called when selecting in the 3d view"""
        '''FreeCAD.Console.PrintMessage(document+"\n")
        FreeCAD.Console.PrintMessage(object+"\n")
        FreeCAD.Console.PrintMessage(element+"\n")
        FreeCAD.Console.PrintMessage(str(position)+"\n")'''
        self.setEditPoints(FreeCAD.getDocument(document).getObject(object))

    def removeSelection(self, document, object, element):
        """Remove single object from selection. Usually gets called when deselecting in the 3d view"""
        self.deleteTrackers(object)

    def setSelection(self, document):
        """Add one or more objects to selection. Usually gets called when selecting in the tree view"""
        self.deleteTrackers()
        self.setEditPoints(FreeCADGui.Selection.getSelection())

    def clearSelection(self, document):
        """Remove all objects of the given document from the selection"""
        self.deleteTrackers()


    def setEditPoints(self,obj):
        #FreeCAD.Console.PrintMessage("\n setting editpoint")
        #FreeCAD.Console.PrintMessage(str(print(selection)))
        pl = None
        
        self.editpoints = []
        
        if "Proxy" in obj.PropertiesList and hasattr(obj.Proxy,"Type"):
                
            objType = Draft.getType(obj)
            FreeCAD.Console.PrintMessage(str(objType)+"\n start editing")
            
            pl = None
            if "Placement" in obj.PropertiesList:
                pl = obj.Placement
                invpl = pl.inverse()
                
            if objType in ["Wire","BSpline"]:
                #self.ui.editUi("Wire")
                for p in obj.Points:
                    if pl: p = pl.multVec(p)
                    self.editpoints.append(p)
                    
            if objType == "Circle":
                self.editpoints.append(obj.Placement.Base)
                #if obj.FirstAngle == obj.LastAngle:#self.obj is a circle
                    #self.ui.editUi("Circle")
                    #self.editpoints.append(obj.Shape.Vertexes[0].Point)
                #else:#self.obj is an arc
                    #self.ui.editUi("Arc")
                    #self.editpoints.append(obj.Shape.Vertexes[0].Point)#First endpoint
                    #self.editpoints.append(obj.Shape.Vertexes[1].Point)#Second endpoint
                    #self.editpoints.append(getArcMid())#Midpoint
                FreeCAD.Console.PrintMessage(str(self.editpoints)+"\n ")

            self.setTrackers(obj)
            #self.proceed()
            return
        FreeCAD.Console.PrintMessage("\n This object type is not editable")
        return
    
    def setTrackers(self,obj):
    
        if self.editpoints:
            FreeCAD.Console.PrintMessage("\n SETTING EDITTRACKER")

            for ep in range(0,len(self.editpoints),1):
                self.trackers.append(editTracker(self.editpoints[ep],obj.Name,ep))
            #self.call = self.view.addEventCallback("SoEvent",self.action)
            #self.running = True
            '''plane.save()
            if "Shape" in self.obj.PropertiesList:
                if plane.weak:
                    plane.alignToFace(self.obj.Shape)
            if self.planetrack:
                self.planetrack.set(self.editpoints[0])'''
        else:
            return
        
        FreeCAD.Console.PrintMessage("trackers lenght = "+ str(len(self.trackers)) + "\n endpoints lenght  = " + str(len(self.editpoints)))

        
    def deleteTrackers(self,object = None):

        if object != None:
            FreeCAD.Console.PrintMessage("trackers lenght = "+ str(len(self.trackers)) + "\n endpoints lenght  = " + str(len(self.editpoints)))
            
            removeIdx = []
            
            for t in range(0,len(self.trackers),1):
                if object == self.trackers[t].name:
                    #FreeCAD.Console.PrintMessage(str(t.idx) + "  "+ str()"\n OBJECT DESELECTED")
                    removeIdx.append(t)
            
            n = 0
            
            for t in removeIdx:
                self.trackers[t-n].finalize()
                self.trackers.pop(t-n)
                n = n + 1
                    
        elif self.trackers:
            for t in self.trackers:
                t.finalize()
            self.trackers.clear()
            self.editpoints.clear()
            self.editpoints = []
            self.trackers = []
            
follow my experiments on BIM modelling for architecture design
User avatar
Moult
Posts: 321
Joined: Sat Jan 05, 2019 11:46 am
Contact:

Re: Draft Edit improvements

Post by Moult »

Hey @carlopav, maybe it's a good time to discuss how we both envision draft editing :)

In a nutshell here's what I'm thinking of:
  1. There are essentially two types of draft objects: graph objects (lines / wires) and parametric objects (arcs / circles / splines, etc). graph objects have subelements (vertices / edges), and parametric objects have editing points (arc handle / circle centroid / etc). This distinction is important because subelements are always visible, but editing points are generally invisible unless the current draft edit mode is activated.
  2. Because subelements are always visible, at any time, any combination of zero or more subelements can then be selected and you can perform transformation modifiers (move / rotate / scale / fillet, align, etc) without the need to create or join new draft objects. This is achieved via a "subelement" mode in those respective modifiers. This is already implemented in my PR for the "move" modifier. I can continue working on this to implement subelement mode for all other transformation modifiers
  3. Also at any time, any combination of zero or more subelements can then be selected and you can perform non-transformation modifiers (copy / array / mirror / etc) in a "subelement" mode, but it will result in brand new draft objects for each non-connected graph of 2 or more vertices. This subelement mode covers the majority of usecases around manipulating graph objects. I can build this, seeing as it's part of the whole subelement mode thing.
  4. Because of this subelement mode, the stretch tool can be deleted. All of its functionality is already included and improved. Easily done by anybody when this code matures
  5. The existing draft edit mode can stay with all of its current functionality + improvements by @carlopav. That is because its primary purpose will now be in modifying editing points for parametric objects. Admittedly, there is a slight double up with the ability to move vertices in the draft edit mode, and the ability to move it using the move command + subelement mode, but that's OK :) Maybe it can be renamed to be more specific to help users understand, to something like draft node mode. @carlopav has already been doing great work in improving this! He should continue!
  6. When working in a complex scene, draft bases and draft elements may be invisible, obscured, or otherwise hard to select. A new draft highlight mode can be activated which finds and shows all draft elements, including invisible component bases (see https://peertube.social/videos/watch/86 ... e332e916f4). This visibility as well as the improved cycle selection should improve the ability to select these draft objects to get ready to manipulate them. This feature is already done in the PR, just needs more testing and maturity
Once all that is done, I think I will be happy with all of the draft editing functionality in FreeCAD :) What do you guys think?
I also blog about 3D rendering, architecture, software and other on thinkMoult.com. RSS / Atom feed available for your convenience.
Post Reply