Created Part is InYourFace [solved]

Need help, or want to share a macro? Post here!
User avatar
iplayfast
Posts: 71
Joined: Sat Sep 07, 2019 6:55 am

Created Part is InYourFace [solved]

Postby iplayfast » Fri Nov 08, 2019 8:33 pm

Hello all, I'm working on a Cycloidal drive library, and am having a few issues.
1. When the parts are created, it is created very close the the screen (in your face), and you have to zoom out to see it.
2. I'm getting strange errors
cycloidbox.py(130)<class 'TypeError'>: function takes at most 5 arguments (6 given)
generated by

Code: Select all

	doc.recompute()

/home/chris/.FreeCAD/Mod/CycloidGearBox/cycloidbox.py(275)<class 'TypeError'>: function takes at most 5 arguments (6 given)
/home/chris/.FreeCAD/Mod/CycloidGearBox/cycloidbox.py(275)<class 'TypeError'>: function takes at most 5 arguments (6 given)
/home/chris/.FreeCAD/Mod/CycloidGearBox/cycloidbox.py(275)<class 'TypeError'>: function takes at most 4 arguments (5 given)
/home/chris/.FreeCAD/Mod/CycloidGearBox/cycloidbox.py(275)<class 'TypeError'>: function takes at most 4 arguments (5 given)
/home/chris/.FreeCAD/Mod/CycloidGearBox/cycloidbox.py(275)<class 'TypeError'>: function takes at most 4 arguments (5 given)
generated by

Code: Select all

 Shape = cycloidFun.generateEccentricShaft(H)
        self.Object.Shape = Shape
Line 275 is the self.Object.Shape = Shape line.
Notice that the same assignment gives different argument errors for the one assignment!

Could this have something to do with json encoding?

Code is at https://github.com/iplayfast/CycloidGearBox

Any help is appreciated.

OS: Linux Mint 19.2 (X-Cinnamon/cinnamon)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18694 (Git) AppImage
Build type: Release
Branch: master
Hash: c3ba04183e016e15410d84bae4d00556d22c7da5
Python version: 3.7.3
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Canada (en_CA)
Last edited by iplayfast on Sat Nov 09, 2019 5:34 pm, edited 1 time in total.
User avatar
iplayfast
Posts: 71
Joined: Sat Sep 07, 2019 6:55 am

Re: Created Part is InYourFace

Postby iplayfast » Fri Nov 08, 2019 8:53 pm

I've solved problem #2 (although I don't know why those particular errors were generated).
So now just need it to not be In My face!
chrisb
Posts: 21375
Joined: Tue Mar 17, 2015 9:14 am

Re: Created Part is InYourFace

Postby chrisb » Fri Nov 08, 2019 9:53 pm

Have a look at the macro FCCamera (or its code).
User avatar
iplayfast
Posts: 71
Joined: Sat Sep 07, 2019 6:55 am

Re: Created Part is InYourFace

Postby iplayfast » Sat Nov 09, 2019 5:34 pm

Thanks, not directly helpful, but it pointed me to what to search for.
I ended up with:

Code: Select all

FreeCADGui.SendMsgToActiveView('ViewFit')
User avatar
DeepSOIC
Posts: 7291
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Created Part is InYourFace [solved]

Postby DeepSOIC » Sat Nov 09, 2019 8:54 pm

iplayfast wrote:
Fri Nov 08, 2019 8:33 pm
1. When the parts are created, it is created very close the the screen (in your face), and you have to zoom out to see it.
This is an interesting problem. I've added a setting in preferences for the default camera zoom not so long ago, I think your freecad version is recent enough to include it. Setting it to the typical sizes of objects you're dealing with a bit of margin with should help a bit. But that doesn't solve the problem when default size of created object isn't anything like your setting.

In Lattice2, I created a rather sophisticated module called "autosize" to drive default sizes and placements of new Lattice2 objects to suit the current camera. I plan on taking that module into FreeCAD, but as I am quite busy with ConstraintSolver now, don't expect it any time soon.
User avatar
iplayfast
Posts: 71
Joined: Sat Sep 07, 2019 6:55 am

Re: Created Part is InYourFace [solved]

Postby iplayfast » Sat Nov 09, 2019 9:05 pm

ViewFit was the easy straightforward solution.