Messing around with the topo-naming issue

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
chrisb
Veteran
Posts: 53926
Joined: Tue Mar 17, 2015 9:14 am

Re: Messing around with the topo-naming issue

Post by chrisb »

You have a dependency cycle:
Attachments
SnipScreenshot-b4083b.png
SnipScreenshot-b4083b.png (14.79 KiB) Viewed 974 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
freedman
Veteran
Posts: 3441
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Messing around with the topo-naming issue

Post by freedman »

chrisb, You have a dependency cycle:
I could also see a dependency error. Is there some way FreeCAD can handle this kind of error so the dependency can be broken because being stuck and having to delete something doesn't seem right. Should there really be a .cpp error for this condition?

In my macro I guess I should delete some supports and retry the attachments.
Thanks
chrisb
Veteran
Posts: 53926
Joined: Tue Mar 17, 2015 9:14 am

Re: Messing around with the topo-naming issue

Post by chrisb »

From the GUI you have two possibilities: select a plane and klick Image or edit the MapMode and reattach the sketch.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
freedman
Veteran
Posts: 3441
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Messing around with the topo-naming issue

Post by freedman »

chrisb, Oh! I see, that is part of the list issue, I need to exclude all face attachments of the feature that I am creating. Da! :) I will need to recreate the list on every recompute because face numbers are all over the place in a broken model.
Thanks.

So far I have been able to fix models by selecting a broken sketch and then cycling that sketch thru all the faces and look (visually) for the correct placement. Once FreeCAD is happy with the placement the recompute moves the error down the tree to the next broken sketch attachment. I do the same cycling to the next sketch and so on.... I will post a crude macro in a few days for folks to play with. I also noticed that as sketches are remapped they might need to be "Map reversed" when reattached.
freedman
Veteran
Posts: 3441
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Messing around with the topo-naming issue

Post by freedman »

I probably should add here that this is experimental territory, I'm sure that if you open large files they will probably get trashed. This is best used on new simple models that are very basic, something created just to watch the faces get remapped. I would say this is for pro users only.

OK! I made some real progress. Here is a macro for us to use and test. It only works on 0.19 and above. You can create models by sketching on faces and if you go back and modify an early sketch you can fix the model. This will allow us to fix topo errors.

It works like this: Create models by sketching on faces and once your finished run this macro or have it running already and click on "update properties", this will create new or update the additional copy of the sketch placement base. Then later when we need it, the macro will try to remap any misplaced sketches to the addition placement copy info. That's about the extent of the concept but the macro has some smarts and it does searching automatically, you just need to click on each sketch one at a time from the first created to the last. The base sketch is excluded because we want to leave it alone. This is really fun to use. With the manual face +- buttons to can move/map the sketch to every available face, and you can click fast, once you find a good home for the sketch then click "recompute to map it there. The sketch object is highlighted and the lines are enlarged so you can better see location. :shock:

The "Seek" button is a toggle On/Off and enables you to remap tree selections automatically and it also sets transparency so you can see inside the solid. "Face +" will move the sketch to the next face, "Face -" will move the sketch to the previous face. Recompute is obvious and Restore will reset the highlighted sketches and the transparency. The tan box is there to give some feedback during usage.

How to use it: Create a model and update properties. Once you have created an error, lets say in a sketch then close the sketch, cick on Seek to turn ON and the model will turn to see-thru. Now you have to start at the lowest sketch other than the base sketch (normally sketch001), we don't want to remap the base sketch. Click on the sketch in the tree. You will see the model sketch get correctly placed or you need to do it manually. If the macro can't find a face that is correct then it will show some text in the tan box. If the face can't be mapped automatically then you will need to do it manually with the Face +- buttons. Once you place the sketch on the correct pad then click recompute. Once finished with the last sketch in the tree, click on restore. If you want, you can map every sketch manually just to see how it works, just highlight the sketch in the tree and apply Face + or face -. Once the model is fixed then you want to click on "update properties" to update all the sketch placements.

This really works! I have messed up many sketches and fixed them in just seconds. There's list of additional things to add to make it more friendly and the code is messy but that's all I had time for. Let me know what you think....

Let me know if the buttons don't look right for a mac.

I also included a model if you want to use it. It can help you see what is going on as sketches are thrown about.
Thanks
Attachments
reface_pic.png
reface_pic.png (4.6 KiB) Viewed 868 times
topo_test3.FCStd
(69.29 KiB) Downloaded 15 times
Last edited by freedman on Fri Jan 08, 2021 8:54 pm, edited 1 time in total.
freedman
Veteran
Posts: 3441
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Messing around with the topo-naming issue

Post by freedman »

Note: I am removing the macro, I have a persistent problem with the space bar and the macro might be related.
chrisb
Veteran
Posts: 53926
Joined: Tue Mar 17, 2015 9:14 am

Re: Messing around with the topo-naming issue

Post by chrisb »

Ok, see you later!
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
freedman
Veteran
Posts: 3441
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Messing around with the topo-naming issue

Post by freedman »

I'm going to take another look at the macro "reface" and try to make it easier and safer to use.

The concept behind it:
The macro is simple in that it just allows placing the selected sketch on all available faces and we can move the sketch (visually) without doing a recompute. The trick that I found is that if the Tip is set to the selected sketch feature then logically the sketch can only be placed on prior valid numbered faces. When we ask for a list of faces from FreeCAD the list ends at the Tip. Once the sketch is placed and a recompute is done then topo-naming is valid at that level of Tip, then we select the next sketch (down the tree) and the associated feature and Tip and do the same thing again. By the time we go thru all the sketches the model is rebuilt. The key to speed is to automate the placement of as many of the sketches as possible and that's where having the placement copy comes in, we can compare the old and new sketch placement and auto place sketches that haven't been changed, they just got renumbered.

What's next, once the sketch stepping process gets refined then automating stepping thru the sketches would be the next phase. Also, if you have a large model there could be hundreds of faces, we need to isolate only the possible faces the sketch could attach to or has attached to.

I have noticed that sometimes external geo will survive the process but most times elements and vertex seem to be renumbered. There's probably a way to detect/fix that also.
Thanks
freedman
Veteran
Posts: 3441
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Messing around with the topo-naming issue

Post by freedman »

Updated macro 1/12/21 ............. I posted the wrong version previously, sorry

I am reposting this experimental macro. I removed the macro for a while but now it works fine. I suggest testing it by creating some new basic models, something you can break by creating a topo-error and then try to fix.

In the pic I created this test model. I added the rectangular holes (yellow arrow) to the base sketch and got a topo-error. I fixed the model in less than 10 seconds using the macro.

It works like this: Start the macro and set it aside, then create models by sketching direct on faces. When you break your model the macro will help you remap misplaced sketches. That's about the extent of the concept but the macro does searching automatically, you just need to click on each sketch one at a time from the first created sketch to the last, the base sketch is excluded from selecting and remapping.
There is also a manual mode where you use face+ and face- buttons, you can move the selected sketch to every available face and you can click fast, once you find a good home for the sketch then click "Recompute" to map it there. The sketch object is highlighted and the lines are enlarged so you can better see location. Depending how you break your model Auto mode might be all you need.

The "Sketch pick OFF" button is a 3 step toggle;
1) Sketch pick Off
2) Sketch pick Auto
3) Sketch pick manual
When turned on (to Auto or Manual) the transparency will allow for see thru, you will then start at the lowest numbered sketch and work your down the tree, select sketches only. Tree sketch selections will try to remap the sketch automatically, give it a few seconds because it needs some time to go thru the lists. If the sketch can't be remapped automatically then the "Properties" button will turn red, this is saying the face placement is broken between the original and the copy. You can then switch to manual mode and use "Face +"and "Face -", the buttons will move the sketch to available faces, a Recompute is required after each manual placement.

How to use it: Create a model and modify an early sketch until you get an error. Once you have created an error, lets say in a sketch then close the sketch, click the macro button to "Sketch pick Auto" and the model will turn to see-thru. Now you have to start at the lowest sketch other than the base sketch (normally sketch001) an click on the sketch in the tree, then the next....... You will see the model sketch get mapped or the error will stay and you need to map it manually. If the macro can't find a face that is correct then it will show in the tree with the exclamation point. If the face can't be mapped automatically then you will need to do it manually with the Face +- buttons, you will then continue down the tree. Turn the Sketch pick to off when finished. Once the model is fixed then you can click on "Properties outdated" to update all the sketch placements,the button will then change to "Properties Updated".

I found the macro requires Preselection to be turned off and also needs version 0.19 and above. The code is messy for sure.

I'm out of time for this project for now. I will do more in a couple months. It works good enough for me to attach all my sketches to faces from now on I believe. Any test data feedback is welcome. Thanks
Attachments
reface_pic.png
reface_pic.png (128.01 KiB) Viewed 686 times
2_reface.FCMacro
(21.6 KiB) Downloaded 10 times
freedman
Veteran
Posts: 3441
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: Messing around with the topo-naming issue

Post by freedman »

The macro works while in Sketcher and is very useful. The pic (left) I sketch in a rectangle on the base sketch and get a topo-naming error. As usual the model freezes (exclamation point in tree) and the pocket does not take place. I stay in sketcher and switch the macro button to "Sketch pick auto", then select sketch001. You can see now (pic right) the macro has processed the model and the pocket occurs. I then process down thru all the sketches and the model is rebuilt completely, all with 7 button clicks. I then close sketcher to a perfect model. Another advantage to this is when "Sketch pick" is turned on we get transparency while sketching. To return the model to solid view click "Sketch pick" to Off.
Attachments
topo_11.png
topo_11.png (431.67 KiB) Viewed 706 times
Post Reply