Temporary interface for A2plus assembly Macro

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
dan-miel
Posts: 391
Joined: Thu Sep 13, 2018 12:29 am
Location: Spokane WA. USA

Temporary interface for A2plus assembly Macro

Post by dan-miel »

I used A2 a few months back and liked the basic program but the interface seemed awkward so I have hacked up a "Macro" for an interface. The concept is that when 2 planes are picked, 95% of the time you want them collinear, picking two axis or edges you want the concentric. When you run this Macro you get this dialog. With checkbox1 on Auto, if you select two faces, the Macro selects Planes_coliner automatically. But, if you want Parallel planes instead select the Parallel radio button before your second pick. If you select Planes_Coliner and enter a value in the Values textbox, then on the second selection the constraint should be made with the offset value. In the startup mode the mate selection reverts to auto after a mate is made.

After a constraint is made the form enters an "edit" mode. You can flip the mate, change the offset, and maybe change the child part. Click the update button to update the offset.


At any time, you can click on a mate in the tree and the Edit window will show with the constraints name in the upper left. You can update the mate or delete it.

If you want to do several mates of the same kind you can click off the Auto checkbox and select the type of constraint you want. If you are building a wall you can select Planes coliner, enter 16 in the offset value and click two studs, every time you click two studs they should be 16inches apart.

Pick hidden: allows you to select a spot on a part or several parts and all of the features below the spot will be listed in a table. You can then move your mouse up and down the table and click in a cell to select the highlighted part.I use this to select vertexes.


The filters do not work.

I created this because I believe it is an easier interface than what comes with A2plus. I would like to fix the problems that are here but i have never worked with Python before. I cannot get pdb to work with the FreeCAD Macros and am at a lost at how to turn this into a .py module so I cannot step thru a program to trouble shot. I have been using Notepad++ as an editor and I'm spending hours trouble shooting a problem that could be found in minutes if I could step and examine values.

If you take a look at the program please give feedback. I'm getting frustrated with the time spent trouble shooting so if anyone has time to give advice on how to get pdb running in a macro or how to move this to a .py file it would be appreciated.
Thanks Dan Miel
Attachments
Picture of interface
Picture of interface
Interface pic.jpg (63.65 KiB) Viewed 2186 times
Quick Pick.FCMacro
macro
(58.38 KiB) Downloaded 59 times
kbwbe
Veteran
Posts: 1052
Joined: Tue Apr 10, 2018 3:12 pm
Location: Germany, near Köln (Cologne)

Re: Temporary interface for A2plus assembly Macro

Post by kbwbe »

Hi @dan-miel,
welcome to the forum.
dan-miel wrote: Mon Nov 26, 2018 10:38 pm but i have never worked with Python before.
Nice work for a Python newbie. ;)

Last day's, i started some work on A2plus user interface within my devel branch. I will take your work as some inspiration for my modifcations.
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
dan-miel
Posts: 391
Joined: Thu Sep 13, 2018 12:29 am
Location: Spokane WA. USA

Re: Temporary interface for A2plus assembly Macro

Post by dan-miel »

Thanks for the comment kbwbe. I normally use MS Visual Studio when programming. Going from their editor with all the debugging tools to a "dumb" editor while trying to learn new syntax is driving me crazy. I would like to step through your programs so I can understand them better but pdb doesn't seem to work with FreeCAD or I'm doing something wrong.
My program is not stable. Sometimes it works great and other times the parts will not move. I will repost when I find what is going on.
I wish i could get the degrees of freedom from your files because I could check and warn the user if he selected two with no freedom.
I don't think I entered all of your constraints in my program but hopefully I just need to make a dictionary for each constraint.
Anyway Thanks
Dan Miel
dan-miel
Posts: 391
Joined: Thu Sep 13, 2018 12:29 am
Location: Spokane WA. USA

Re: Temporary interface for A2plus assembly Macro

Post by dan-miel »

Information for using the A2plus Temporary interface
Around line 40 I tried to write a few lines to point the program to the A2plus directory. Some people or everyone may need to hardcode the path to the A2plus files in line 42.

I don’t think I entered all of the constraints into the program. They are controlled by the dictionaries around line 220. These hold the information that I use to determine which constraint to use when in Auto mode and checks the features when the user selects a constraint. The first dictionary matches the ‘Auto’ radio button so will never be picked. The isdefault, if marked ‘y’ is picked as the default constraint when the user selected features matches the features in the featsurList. When two planes are picked I have the coincident set as default. If you want the planes parallel to be the default when two planes are pick you could set the isdefault to yes, but I don’t think that is practical.

What might be harder to understand is the featsurList. I figure that the main features we are working with are Face, Axis, Edge, Vertex. There are two features per constraint. Most features are either flat or curved. In the featsurlist I listed the feature and next to it the type of matching surface. If the user picks a flat surface this program runs down the featsurList and compares the feat (Face) and the surface (flat equals <Plane object>) when it finds a match, it then compares the next user selected feature. When the program detects two matches in one list and the isdefault is ‘y’ it picks that constraint to run.
The list is also used when the user selects a constraint. I run the selected surfaces through the list to insure that the features match the constraint.
I hope this helps if you want to add missing constraints.
dan-miel
Posts: 391
Joined: Thu Sep 13, 2018 12:29 am
Location: Spokane WA. USA

Re: Temporary interface for A2plus assembly Macro

Post by dan-miel »

This is still buggy but I fixed a few of the bugs.
I believe that all of the constraints work but for the Angled planes. This will enter the degrees but will not update the graphics. After a while the graphics will sometimes update.

with the high light constraints: If Show object is selected you can click a part or constraint in the tree and the mates will highlight. The parts show all of the mates and then you can arrow up and down to see the separate mates.

The lower button "List Part properties" Is similar but with a table. It also shows which parts are fixed and by clicking in the first column you can toggle between fixed or not.
A date revision is in the upper left.


I took some time to find better debug tools. Started using the MS Editor. As for pdb. I seldom use the Python Console because of tremors. I have also been working on a small laptop so I have few apps open. A couple days ago I got on my desk top with two screens and there was the console, figured out the console is where the input is for pdb. What a idiot I am.
Dan
Attachments
Quick Pick.FCMacro
Constraints work. Still buggy
(60.73 KiB) Downloaded 45 times
dan-miel
Posts: 391
Joined: Thu Sep 13, 2018 12:29 am
Location: Spokane WA. USA

Re: Temporary interface for A2plus assembly Macro

Post by dan-miel »

Here is the latest update of this macro. I am a Python and FreeCAD newbie so I’m not sur how well this will work on any other machine or if it will work at all. If someone is willing to try and install it, I would appreciate any feedback they may have.
Also some demo videos to give an idea of how it works on my machine.
Dan.

This macro is only a small interface for A2plus. It does not replace A2plus. It is written with Python 2.7.14 that came with FreeCAD 0.17.

phpBB [video]
phpBB [video]
phpBB [video]
phpBB [video]
Attachments
Quick Pick.FCMacro
(83.52 KiB) Downloaded 51 times
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Temporary interface for A2plus assembly Macro

Post by triplus »

Looks nice. I can see the usefulness but i am wondering if such complex dialog could demotivate end users. As instead add relation related commands having "continue mode" and having some selection/view oriented commands provided as a standalone. I wonder if for an average end user such approach would be easier to grasp and to use.
dan-miel
Posts: 391
Joined: Thu Sep 13, 2018 12:29 am
Location: Spokane WA. USA

Re: Temporary interface for A2plus assembly Macro

Post by dan-miel »

triplus wrote: Fri Dec 28, 2018 9:17 am Looks nice. I can see the usefulness but i am wondering if such complex dialog could demotivate end users. As instead add relation related commands having "continue mode" and having some selection/view oriented commands provided as a standalone. I wonder if for an average end user such approach would be easier to grasp and to use.
12 15 with s

I had not thought of the complexity of the form, I had thought of the screen space it gobbles up. Lower left has two buttons for reducing size but I should take them off.
Besides the question of if it works on other machine, SPEED and EASE OF USE is what I would like to test. It appears that on the A2plus that is being released, ver18?, there are six button clicks and two screens in order to create one constraint (steps are below). With this Quick interface, for the most common constraints there are two button clicks. If you want one that is not a default, there are three clicks. When an assembly has 50 parts, the number of clicks is 50 parts 3 constraints per part * 7 steps = 1,050 vs 50*3*2 = 300 for Quick.

In A2+, to edit a constraint you open another dialog. It is the same as the create dialog which I think is good. With Quick the editing and troubleshooting is all on one form so you don’t need to change back and forth.
I am in no way saying A2+ is bad. I like the program and these guys have written a program that I would never be able to write. This interface, for me, is quicker and remembers some of the steps for me plus it has the hidden surface feature.
If other people find it useful or it saves them time, I can make a less scary form in the future.
Thanks for the insight.
Dan

Steps per constraint
A2plus Standard A2plus with Quick

1 Select first entity Select first entity
2 Hold down ctr key Select second entity
3 Select second entity
4 Release ctr key
5 Select mate type from dialog
6 Press accept
7 Press Solve
8 Press Accept
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Temporary interface for A2plus assembly Macro

Post by triplus »

dan-miel wrote: Fri Dec 28, 2018 4:26 pm 1 Select first entity Select first entity
2 Hold down ctr key Select second entity
3 Select second entity
4 Release ctr key
5 Select mate type from dialog
6 Press accept
7 Press Solve
8 Press Accept
Yes such "long procedure" was shortened a bit by the introduction of the Continue mode. That happened in for example Draft/Sketcher geometry/constraint creation process. The way it could work for assemblies is:
  • Select one of the available relations - For example Plane Parallel.
  • Plane Parallel command now remains in active/continue mode and therefore end user needs to select plane pairs, one pair after another.
Well i guess basically what your dialog does. ;)
Post Reply