Operazioni Booleane Animate

Forum per le domande e le discussioni in Italiano
Forum rules
regole del forum e le informazioni utili

Importante: PRIMA di chiedere aiuto leggete qui!
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Operazioni Booleane Animate

Post by microelly2 »

francesco9191 wrote: It's very slow because of there are many boolean operations
In my animation workbench I have a collision node which is not the same what you do but shown only collisions
To speed up the animation I cache the data:

The Snapshot records all the shapes
The View_Collision_Sequence can then run trough all configurations in realtime

See here the demo
https://youtu.be/hyVJJL2eFn0

The programming details you find in my git: https://github.com/microelly2/Animation

BTW, your idea to reuse the difference body for the next animation step is intersting,

I will it adopt to my workbench and extend my slicer/filler :)
https://youtu.be/qT8u7NjSZ4c
milling and extrusion
https://youtu.be/PnKP89KqSLg
https://youtu.be/676TMEyMmdg
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Operazioni Booleane Animate

Post by microelly2 »

Inspired by your example I have added such a functionality to my Animation workbench.
It's time consuming because the figures become very complex, but collecting all steps as images can be used to greate a movie.

https://youtu.be/d07gVQ3v8JU
renatorivo
Veteran
Posts: 2611
Joined: Tue Feb 21, 2012 8:07 pm
Location: Torino - Italy

Re: Operazioni Booleane Animate

Post by renatorivo »

Chi vuole solo vedere il cilindro che "rosicchia" il cubo può provare questo codice ottenuto modificando il lavoro di Francesco e di microelly2, non è certamente professionale, ma funziona:

Code: Select all

from FreeCAD import Gui                         
from PySide import QtCore
from FreeCAD import Draft, Base
import Part
import math as mt
from math import sin, tan, log

App.newDocument("Senza nome")
App.setActiveDocument("Senza_nome")
App.ActiveDocument=App.getDocument("Senza_nome")
Gui.ActiveDocument=Gui.getDocument("Senza_nome")

#CILINDRO(UTENSILE)
cilindro=Part.makeCylinder(10,300,Base.Vector(0,0,0),Base.Vector(0,0,1),360)   
cilindro_shape = App.ActiveDocument.addObject("Part::Feature", "cilindro")
cilindro_shape.Shape = cilindro
Gui.ActiveDocument.getObject("cilindro").Visibility=True

#CUBO(PEZZO GREZZO)
cubo=Part.makeBox(300,300,300,Base.Vector(0,0,0),Base.Vector(0,0,1))
cubo_shape = App.ActiveDocument.addObject("Part::Feature", "cubo")
cubo_shape.Shape = cubo
Gui.ActiveDocument.getObject("cubo").Visibility=False

#DEFINIZIONE OPERAZIONE BOOLEANA INIZIALE
diff = cubo_shape.Shape.cut(cilindro_shape.Shape)

Part.show(diff)

Gui.SendMsgToActiveView("ViewFit")

i=0

def mov():
  global i, diff
  i+=1

  diff = diff.cut(cilindro_shape.Shape)

  #App.getDocument("Senza_nome").cubo.Placement=App.Placement(App.Vector(0,-i,0), App.Rotation(App.Vector(0,0,1),0), App.Vector(0,0,0))
  App.getDocument("Senza_nome").cilindro.Placement=App.Placement(App.Vector(i,i,0), App.Rotation(App.Vector(0,0,1),0), App.Vector(0,0,0))
 
  App.ActiveDocument.removeObject("Shape")
  diff.removeSplitter()
  Part.show(diff)

#TIMER PER IL MOTO   
timer = QtCore.QTimer()
timer.timeout.connect(mov)
# timer.start(1)


import time

for i in range(300):
   mov()
   time.sleep(0.01)
   Gui.updateGui()
Renato
Post Reply