How to fix Sketch orientation?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
chrisb
Veteran
Posts: 54150
Joined: Tue Mar 17, 2015 9:14 am

How to fix Sketch orientation?

Post by chrisb »

I have this sketch, which is an extract from a bigger model which I made last year or so. The model now showed errors just on opening. I traced it to this sketch, which shows cumbersome behaviour:
- load the file
- edit the sketch
- switch to the model tab and make the sketch visible:
SnipScreenshot-c99882.png
SnipScreenshot-c99882.png (11 KiB) Viewed 1153 times
You see that the orientation outside of sketcher is different from the (correct) orientation shown in sketcher. Recompute doesn't help.
How can I fix it?
Attachments
sketchOrientation.FCStd
(3.83 KiB) Downloaded 29 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
drmacro
Veteran
Posts: 8974
Joined: Sun Mar 02, 2014 4:35 pm

Re: How to fix Sketch orientation?

Post by drmacro »

Is the sketch placement supposed to be:
Snip macro screenshot-e15f15.png
Snip macro screenshot-e15f15.png (40.28 KiB) Viewed 1143 times
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
TheMarkster
Veteran
Posts: 5508
Joined: Thu Apr 05, 2018 1:53 am

Re: How to fix Sketch orientation?

Post by TheMarkster »

I remember NormandC remarking once how he never liked to leave sketches unattached. Perhaps issues like this is what he alluded to. If you attach it to something, and then adjust attachment offset to put it back where it was originally the problem disappears. I have 2 macros I use, based on work done by DeepSOIC and Kisolre. I call them phase1 and phase2 for lack of more imaginative names. Phase1 copies the current sketch placement. To use, select the sketch and run the macro. Next attach the sketch to something, anything, with any desired attachment mode. Then select the sketch again and run phase2. Phase2 modifies the attachment offset such that now the sketch is back in its original placement position.

In PD you could use the xy_plane, etc. In the attached file I added a cylinder to have something to compare the orientation of the sketch to. I attached the sketch concentrically to the top circle edge.

phase1:

Code: Select all

#select the sketch to be reattached. Then run next two lines.
#from DeepSOIC and Kisolre
#part 1 of 2 sketch remapping
#in this part we simply get the current placement and save it
#the next phase is to manually attach the sketch to some desired object
#and then run phase 2, which will calculate the correct attachment offset to
#use with the new attachment to put the sketch back into the current location/rotation
sk = Gui.Selection.getSelection()[0]
FreeCAD.old_placement = sk.Placement
print ("Placement get from", sk.Label)
phase2:

Code: Select all

#phase 2 now will calculate the attachment offset needed to put the sketch back where it was
#while at the same time remaining attached to the current object

#now, reattach the sketch, close attachment dialog. When done, run the rest of the script
sk = Gui.Selection.getSelection()[0]
att_plm = sk.Attacher.calculateAttachedPlacement(sk.Placement).multiply(sk.AttachmentOffset.inverse())
try:
	att_offset = att_plm.inverse().multiply(FreeCAD.old_placement)
	sk.AttachmentOffset = att_offset
	print("Placement restored to ", sk.Label)
except:
	print("use PlacementGet first")
Attachments
sketchOrientation_markster.FCStd
(7.07 KiB) Downloaded 19 times
chrisb
Veteran
Posts: 54150
Joined: Tue Mar 17, 2015 9:14 am

Re: How to fix Sketch orientation?

Post by chrisb »

drmacro wrote: Tue Aug 03, 2021 1:01 pm Is the sketch placement supposed to be:
Yes, that's the correct placement. I recreated it in a new sketch with another obscurity: The angle of the placement is always rounded to 122.9° instead of 122.928.
I don't really remember how I did it then, I had created the model after after old technical drawings.

OS: macOS 10.16
Word size of FreeCAD: 64-bit
Version: 0.20.25311 (Git)
Build type: Release
Branch: master
Hash: c5524bb58a7126fa2242d6137eb82ee9d54e82d4
Python version: 3.9.6
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: C/Default (C)
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
drmacro
Veteran
Posts: 8974
Joined: Sun Mar 02, 2014 4:35 pm

Re: How to fix Sketch orientation?

Post by drmacro »

chrisb wrote: Tue Aug 03, 2021 4:22 pm ...
I don't really remember how I did it then, I had created the model after after old technical drawings.
...
Been there, done that... :mrgreen:
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
chrisb
Veteran
Posts: 54150
Joined: Tue Mar 17, 2015 9:14 am

Re: How to fix Sketch orientation?

Post by chrisb »

Here is an image made with an old 0.18 version. I would not like to upload the whole file because there are other errors too which I would like to fix. IIRC I had uploaded something to the Showcase forum.
Attachments
Bildschirmfoto 2021-08-03 um 18.36.28.png
Bildschirmfoto 2021-08-03 um 18.36.28.png (542.73 KiB) Viewed 1070 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 54150
Joined: Tue Mar 17, 2015 9:14 am

Re: How to fix Sketch orientation?

Post by chrisb »

TheMarkster wrote: Tue Aug 03, 2021 3:26 pm If you attach it to something, and then adjust attachment offset to put it back where it was originally the problem disappears.
Thanks, that did the trick! I know we are of different opinions about the attach/not attach topic, but here your technique was very helpful :D .
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
domad
Veteran
Posts: 2090
Joined: Mon Jun 22, 2020 12:16 pm

Re: How to fix Sketch orientation?

Post by domad »

Good evening to the Community!

.... I think that's okay too
Attachments
sketch_orientation_modify.gif
sketch_orientation_modify.gif (968.66 KiB) Viewed 1012 times
chrisb
Veteran
Posts: 54150
Joined: Tue Mar 17, 2015 9:14 am

Re: How to fix Sketch orientation?

Post by chrisb »

Thanks for your time and ideas. I got it fixed. Several primitives had changed their topo names, some sketches had flipped. Now only the exploded assembly is left to be fixed.
Attachments
SnipScreenshot-209ca8.png
SnipScreenshot-209ca8.png (78.52 KiB) Viewed 964 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
freedman
Veteran
Posts: 3464
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: How to fix Sketch orientation?

Post by freedman »

This is what I use. It's the same code posted by DeepSOIC and Kisolre only I made it a one step process and put it in a easy to use Dialog, see pic. This will take any Sketch and change it's Support (to the selected) while preserving sketch location. By using this you can attach sketches to faces and then reattach them to standard planes. You loose parametrics but gain stability. I don't modify map mode.

There are some great uses to lock sketches to where the face is or was. Sketching on a face and then re-support the sketch can be a really good option if you need to keep something locked in place. For the new users, this will remove parametrics from the sketch attachment.

Edit: Check out that brake shoe, it's a 350 degree pad :) , I have never seen that before.
Attachments
Renew_support1.FCMacro
(5.07 KiB) Downloaded 20 times
SUP_PIC.JPG
SUP_PIC.JPG (16.62 KiB) Viewed 941 times
Post Reply