This will allow you to bring in a bunch of parts (part containers only) and move them around quickly, just click and drag (using Gesture mode). The mouse runs on a toggle, one click selects the part and the next deselects. Load the model then the macro.
You can rotate the view (left button down) in real time while you move parts around. I have to say, this is really fun, some of the best fun I have had using FreeCAD. Moving too fast can can cause some jump around while moving, slow down and zoom in. This is work in progress.
All objects are referenced off of a floor or the ground, everything is referenced to 0.0 on the Z axis. The goal of the macro is to model real life stuff that sits on the ground like your house, your garage or shop, your farm, actually anything that reacts to gravity..... If you don't know the word "Sim", it started off as a simulated real world video game.
I started this so I could create models of my shop and move benches and machines around using FreeCAD.
I included a start file and an end file to give you something to test with, the goal is to open the start file and move all the objects around to make the model space look like the end file (see pics).
All the objects are drawn to scale (approx.). Start the edit with moving the shop to it's location, then edit the name (see #4 below). You will see the floor is already placed that way.
This is a work in progress so please look at it that way.
Controls.
1) shift + Q = end macro
2) Shift + A = Enable/disable toggle
3) Shift + Z = rotate selected object (move the mouse to update object view)
4) Part container names (in the tree) that start with "L_" won't be mouse selectable, this is used to keep an object in it's place.
Note: Don't do a multiple select.
I will be posting in the Macro forums for help on code optimization.
Future additions:
1) Move objects on terrain. Objects track on the face of a loft for instance.
2) Select a top face and make that the new floor (Z axis). This would be used for stacking or to place items on a table.
3) Find or ask for FreeCAD features to make parts better selectable/movable. Optimize cursor tracking.
4) Select other axis
5) Multiple object select
I can edit the file "Start" and make it look like "End" in about 1 minute.
Have fun!
New macro "SIM1". Core code only
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
New macro "SIM1". Core code only
- Attachments
-
- Start_snip.JPG (64.7 KiB) Viewed 982 times
-
- End_snip.JPG (57.66 KiB) Viewed 982 times
Last edited by freedman on Thu Feb 06, 2020 5:23 pm, edited 1 time in total.
Re: New macro "SIM1". Core code only
hi
good work
2) Select a top face and make that the new floor (Z axis). very interesting
6) rotation step by step (90° , 45°, 10°...) good
mario
good work
2) Select a top face and make that the new floor (Z axis). very interesting
6) rotation step by step (90° , 45°, 10°...) good
mario
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.
My macros on Gist.github here complete macros Wiki and forum.
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: New macro "SIM1". Core code only
Cool. The movement of objects is sometimes wobbly (particularly with that building thing).
Doesn't work on touchscreen though. I can pick the object with a tap, and drop it with a tap, but it doesn't move the distance between taps. It's probably not going to be useful... but maybe it can be fixed.
I will use that tool to plan room layout, if I ever decide to move some furniture.
Doesn't work on touchscreen though. I can pick the object with a tap, and drop it with a tap, but it doesn't move the distance between taps. It's probably not going to be useful... but maybe it can be fixed.
I will use that tool to plan room layout, if I ever decide to move some furniture.
Re: New macro "SIM1". Core code only
I'll bet I spent 40 to 50 hours working out the different coordinate and selection interactions. I need a break from that . I will find a way to get smooth dragging.Cool. The movement of objects is sometimes wobbly (particularly with that building thing).
One of my goals; My house is a daylight basement so there are two floor levels and two ground levels with terrain profiles. I will get to a place where I can move furniture and outdoor items at different levels. I would think that by dragging one item over the other the Z axis of the stationary body can be detected and used as a base Z axis. This should allow objects to be moved and stacked quickly.
I will try FreeCAD on my tablet. I know there are a bunch of screen/finger options.Doesn't work on touchscreen though
Thanks
Re: New macro "SIM1". Core code only
I made some good progress on Sim1. I fixed the jumping around issue when objects are dragged and worked out some temporary fixes for moving objects to different levels. I hard coded 3 levels in the attached macro for testing, they are pad,pad001,pad002. As you drag objects they will snap to the different levels. One thing I need to fix, when an object is first mouse selected it's zero point jumps to the cursor, I'm working on that, you will notice it when selecting large objects like the shop.
When I get this to actually work in 0.19 with link, huge sim models could be built in a small file size.
I will delete the previous generated files as I make upgrades.
A thank you goes out to all for answering my posted software questions in the past, it has allowed me to build something like this.
If looking for instructions on how to use "Sim1", goto the first post.
When I get this to actually work in 0.19 with link, huge sim models could be built in a small file size.
I will delete the previous generated files as I make upgrades.
A thank you goes out to all for answering my posted software questions in the past, it has allowed me to build something like this.
If looking for instructions on how to use "Sim1", goto the first post.
- Attachments
-
- 1A_sim_1.FCMacro
- (5.64 KiB) Downloaded 15 times
-
- sim_3_levels.JPG (56.81 KiB) Viewed 824 times
-
- sim_level_test2.FCStd
- (695.39 KiB) Downloaded 14 times
Last edited by freedman on Thu Feb 06, 2020 5:25 pm, edited 1 time in total.
Re: New macro "SIM1". Core code only
Screencast please?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: New macro "SIM1". Core code only
I wish I could do a screen cast, I am stealing time from other important things so I can't. The tools are here, maybe someone else can jump in.
Thanks
As far I know, for best operation use 0.18 and I typically turn off pre-selection. That's it, should work.
I'm just going to presume everyone can see the potential of using this in all different axis, not just XY.
Thanks
As far I know, for best operation use 0.18 and I typically turn off pre-selection. That's it, should work.
I'm just going to presume everyone can see the potential of using this in all different axis, not just XY.
Last edited by freedman on Thu Feb 06, 2020 8:37 pm, edited 1 time in total.
Re: New macro "SIM1". Core code only
Mod edit: Moved to Python Scripting Macros subforum
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: New macro "SIM1". Core code only
I have made some good progress with Sim1. I will update the macro later. Here are a couple pics. Major new features:
1) As selected objects are mouse dragged they will automatically move on top of other objects. The radio tower was made by stacking 10ft sections, these sections were stacked by simple mouse dragging of the objects.
2) If a selected object is mouse dragged onto a flat surface it changes to mostly transparent, this is really useful to place objects. The object turns back to solid once placed.
3) Terrain following; in the pics the power poles are mouse dragged and follow the terrain as they go. No special commands required, all objects selected and dragged will follow the terrain at it's base. This is really why I started on this macro and it works great.
I have fixed pretty much all the mouse selection, placing objects, identifing faces, jerking mouse movements. I put my 11 year old nephew on it and he wanted to turn the truck into a ferrari and change the colors, Hmmm, I was hoping for more . I did put a business guy on it and he really liked moving stuff around in 3D.
My goal here is to do any kind of 3D layout. I also hope to one day approach a school system with the FreeCAD program.
I will work on the user interface next.
1) As selected objects are mouse dragged they will automatically move on top of other objects. The radio tower was made by stacking 10ft sections, these sections were stacked by simple mouse dragging of the objects.
2) If a selected object is mouse dragged onto a flat surface it changes to mostly transparent, this is really useful to place objects. The object turns back to solid once placed.
3) Terrain following; in the pics the power poles are mouse dragged and follow the terrain as they go. No special commands required, all objects selected and dragged will follow the terrain at it's base. This is really why I started on this macro and it works great.
I have fixed pretty much all the mouse selection, placing objects, identifing faces, jerking mouse movements. I put my 11 year old nephew on it and he wanted to turn the truck into a ferrari and change the colors, Hmmm, I was hoping for more . I did put a business guy on it and he really liked moving stuff around in 3D.
My goal here is to do any kind of 3D layout. I also hope to one day approach a school system with the FreeCAD program.
I will work on the user interface next.
- Attachments
-
- sim20.FCStd
- (867.1 KiB) Downloaded 16 times
-
- sim21.JPG (51.82 KiB) Viewed 688 times
-
- sim20.JPG (63 KiB) Viewed 688 times