Drag part elements

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Drag part elements

Post by stefankorisnik3 »

Given an simple object Part::Box how can i in the FreeCAD drag some vertex and pull it in some direction and get some deformation on the object?
I know how to register events to listen for the mouse.
I'm asking is it possible in the FreeCAD to update position of the selected element and automatically get the other adjacents elements to the selected element to follow up or do i have to recreate every time whole object manually?

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * CurvedShapes 1.0.3
  * Curves 0.5.2
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Drag part elements

Post by edwilliams16 »

stefankorisnik3 wrote: Tue Aug 02, 2022 3:24 pm Given an simple object Part::Box how can i in the FreeCAD drag some vertex and pull it in some direction and get some deformation on the object?
You can translate objects and you can do affine (ie including shear) transformations on an object, but as far as I know if you want to change a vertex position, leaving the rest fixed, you would have to rebuild the object with the appropriate edges and faces changed. Others may know if that has be coded by someone.
This seems more like a mesh operation, where you have the luxury of assuming that edges are straight and faces are flat.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Drag part elements

Post by Roy_043 »

carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Drag part elements

Post by carlopav »

Thanks @Roy_043 to mention it. It was originally coded in this PR: https://github.com/FreeCAD/FreeCAD/pull/3716
follow my experiments on BIM modelling for architecture design
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: Drag part elements

Post by mario52 »

Attachments
TextOnSurface00.gif
TextOnSurface00.gif (876.46 KiB) Viewed 544 times
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
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Drag part elements

Post by onekk »

mario52 wrote: Wed Aug 03, 2022 6:58 pm and now i play with the beautiful macro of @onekk (in progress)
Thanks, but most of the work is from @Chris_G and @mfro, I've only bothered a little and made some glue to keep things togheter.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
stefankorisnik3
Posts: 101
Joined: Sun Jul 24, 2022 12:49 pm

Re: Drag part elements

Post by stefankorisnik3 »

Thanks to all. I didn't get to lookup all this things but planning.
Can you let me know
If i need to change single vertex in some solid object
I can find with the ancestorsOfType method the parents faces of the vertex
and further i can find the edges that are adjacent to the vertex.
Can you let me know how can i update the things in most minimal way?
How can i replace the edges in the parents faces?
Is the next thinking okay for the most minimal way:
1.Do i copy the whole array of faces from shell in the new array ?
2.Then i find and delete the parents faces in the new array with the method isSame ?
3.Insert newly created (updated the found parents) faces in the new array at the end ?
4.Construct new shell from the faces in the new array ?
Post Reply