A2Plus part placement

Discussion about the development of the Assembly workbench.
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Postby Buddy Hy » Thu Sep 19, 2019 10:16 pm

Thanks Syres,
I found the magnifying glass, I thought that was for zooming in (I was expecting the constraints to be highlighted as soon as I selected them, like the rest of FreeCAD).
It is a great program to start for my simple test, but my real project will me much more complicated - it may still be enough, but I'd like more info in writing python macro's. Is there a python FAQ on the web somewhere specifically for FreeCAD?
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Postby Buddy Hy » Fri Sep 20, 2019 10:38 am

Don't worry y'all, I just found the python scripting forum - I'll look through that.
Syres
Posts: 385
Joined: Thu Aug 09, 2018 11:14 am

Re: A2Plus part placement

Postby Syres » Fri Sep 20, 2019 1:40 pm

There is the Wiki https://www.freecadweb.org/wiki/Python and the main Macro repository https://github.com/FreeCAD/FreeCAD-macros to have a look through.
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Postby Buddy Hy » Fri Sep 20, 2019 10:52 pm

Hi All, Me again.

I'm trying to use Klaus' script on my test model. I changed the active element in the code from 'star-wheel_001' to 'disc_001' and centred the #position and #center Base.Vectors, but when I run the code I get the following error:

File "C:/Users/AppData/Roaming/FreeCAD/Macro/simulation - test.py", line 31, in <module>
sw.Placement.Rotation.Angle = math.radians(angle)
<class 'AttributeError'>: 'NoneType' object has no attribute 'Placement'

I had hoped it would be that easy but alas, no.
Attachments
simulation - test.py
(781 Bytes) Downloaded 14 times
test.FCStd
(13.6 KiB) Downloaded 14 times
kbwbe
Posts: 881
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: A2Plus part placement

Postby kbwbe » Sat Sep 21, 2019 9:51 am

Buddy Hy wrote:
Fri Sep 20, 2019 10:52 pm
File "C:/Users/AppData/Roaming/FreeCAD/Macro/simulation - test.py", line 31, in <module>
sw.Placement.Rotation.Angle = math.radians(angle)
<class 'AttributeError'>: 'NoneType' object has no attribute 'Placement'
you need to use the real object's name within in the makro. "disk_001" is the label, the object name is "b_disc_001_". You can see the real object name within the status line when hovering with the mouse over the object. Using the object name instead of the label should work.
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.30, installable via FreeCAD's addon manager
Tutorials:
Paul Randall: https://youtu.be/mnkecA9S7kc
anisim (deutsch): https://www.youtube.com/watch?v=vDcaFq6IEJM
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Postby Buddy Hy » Sat Sep 21, 2019 12:45 pm

Hey kbwbe, that worked (though I still have errors) - But why are the names different? And how can I make them the same when creating new objects??
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Postby Buddy Hy » Tue Sep 24, 2019 9:07 pm

Well All, after many attempts I finally got everything placed and all but one constraints fixed. The last constraint I'm having problems with is a pin within a slot. I've tried several types of constraint, but none work.

So now I'm wondering if it's possible to do what I want? What constraints would you use??
Attachments
Assembly simulation.py
(788 Bytes) Downloaded 14 times
Assembly B.FCStd
(15.51 KiB) Downloaded 20 times
kbwbe
Posts: 881
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: A2Plus part placement

Postby kbwbe » Wed Sep 25, 2019 9:41 am

Buddy Hy wrote:
Tue Sep 24, 2019 9:07 pm
Well All, after many attempts I finally got everything placed and all but one constraints fixed. The last constraint I'm having problems with is a pin within a slot. I've tried several types of constraint, but none work.

So now I'm wondering if it's possible to do what I want? What constraints would you use??
You should use "pointOnPlane" constraint with an offset.
- Select a circle of your pin (the center is taken as point)
- Second select a guiding plane within your slot
- Solve the constraint, adjust the offset, so that the pin is in the middle of the slot
KBWBE

https://github.com/kbwbe/A2plus
latest release: v0.4.30, installable via FreeCAD's addon manager
Tutorials:
Paul Randall: https://youtu.be/mnkecA9S7kc
anisim (deutsch): https://www.youtube.com/watch?v=vDcaFq6IEJM
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Postby Buddy Hy » Thu Sep 26, 2019 1:00 am

Thanks kbwbe, I used that constraint a few times but thought there was something wrong as it moved things around - I didn't realise I had to fudge it.

Anyways, I've got everything constrained now but when I run the macro simulation it goes well for a while then all of a sudden the slide shaft moves to an odd spot - and I'm not even modifying it in the macro. I've attached a screen grab of it happening.

Can anyone tell me what's happening and how to fix it?
Attachments
aHuVTXD7YB.gif
aHuVTXD7YB.gif (836.18 KiB) Viewed 363 times
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Postby Buddy Hy » Fri Sep 27, 2019 7:46 am

I figured out it happens at 92.0º...

Code: Select all

convergency-conter: 151
Calculation stopped, no convergency anymore!
TARGET   POS-ACCURACY :0.0001
REACHED  POS-ACCURACY :4.009838451613753e-05
TARGET  SPIN-ACCURACY :0.0001
REACHED SPIN-ACCURACY :9.71729650378849e-05
SA SPIN-ACCURACY      :0.0036838839944608303