A2Plus part placement

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Post by Buddy Hy »

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

Post by Buddy Hy »

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

Re: A2Plus part placement

Post by Syres »

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

Post by Buddy Hy »

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 49 times
test.FCStd
(13.6 KiB) Downloaded 45 times
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: A2Plus part placement

Post by kbwbe »

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.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Post by Buddy Hy »

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

Post by Buddy Hy »

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 53 times
Assembly B.FCStd
(15.51 KiB) Downloaded 62 times
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: A2Plus part placement

Post by kbwbe »

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.56, installable via FreeCAD's addon manager
Tutorial: gripper assembly https://www.youtube.com/watch?v=QMxcQ5tssWk
Documentation: https://www.freecadweb.org/wiki/A2plus_Workbench
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Post by Buddy Hy »

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 1586 times
Buddy Hy
Posts: 32
Joined: Sat Aug 31, 2019 11:30 am

Re: A2Plus part placement

Post by Buddy Hy »

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
Post Reply