Shake Sketch cannot import Part

Need help, or want to share a macro? Post here!
bkw
Posts: 25
Joined: Tue Mar 01, 2016 12:18 am

Shake Sketch cannot import Part

Postby bkw » Fri Mar 04, 2016 1:08 am

I'm trying to figure out what is the one degree of freedom in the sketch "cf reader holder base" in this drawing:
https://drive.google.com/open?id=0Bys6e ... zlaV3V6X3M

To that end I found this macro mentioned in another forum thread:
http://www.freecadweb.org/wiki/index.ph ... ake_Sketch

When I try to run the macro nothing visible happens to the drawing, and I get an error message in the status bar about "cannot import Part"

Did the Part library get renamed or is it part of some other library now, or something else?
Is there a FC 0.16 version of this macro or something like it?

OS: Mac OS X
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6613 (Git)
Build type: Release
Branch: (detached from 80214fb)
Hash: 80214fbfb0a9652a1e0bf2b1e540ee229e68d108
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.8.0.oce-0.17

--
bkw
galou_breizh
Posts: 325
Joined: Wed Sep 15, 2010 9:38 am

Re: Shake Sketch cannot import Part

Postby galou_breizh » Fri Mar 04, 2016 11:28 am

There was an incompability between Windows and Linux. I thought this had been solved both in the macro and in FreeCAD itself. Can you try to replace

Code: Select all

from FreeCAD import Part
with

Code: Select all

import Part
If this doesn't help the problem must be with you installation or there is another incompatibility with Mac. Please report.

Gaël
cox
Posts: 963
Joined: Wed Nov 26, 2014 11:37 pm

Re: Shake Sketch cannot import Part

Postby cox » Fri Mar 04, 2016 12:10 pm

Some mounts ago I saw something similar but I could not reproduce.
Need help? Feel free to ask, but please read the guidelines first
User avatar
DeepSOIC
Posts: 7829
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Shake Sketch cannot import Part

Postby DeepSOIC » Fri Mar 04, 2016 1:14 pm

bkw wrote:... I get an error message in the status bar about "cannot import Part"
Can you please open Report View window, and copy-paste the full error message here? it may help..

To open report view, go to menu View->Panels->Report view. If you don't see your error message there, right-click the report window and verify printing of errors and python errors is switched on.
bkw
Posts: 25
Joined: Tue Mar 01, 2016 12:18 am

Re: Shake Sketch cannot import Part

Postby bkw » Fri Mar 04, 2016 3:30 pm

Before making the suggested edit:
--------
IndexedMap
Clear constraints to external geometry
Traceback (most recent call last):
File "/Users/bkw/Library/Preferences/FreeCAD/Macro/Shake Sketch.FCMacro", line 26, in <module>
from FreeCAD import Part
<type 'exceptions.ImportError'>: cannot import name Part
---------


After making the suggested edit:
---------
IndexedMap
Clear constraints to external geometry
---------

So that looks like it cleared that up.

It still doesn't do anything, but now it looks like it's just because of the external geometry, which I don't want to remove, but no longer broken.

Thanks much.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Shake Sketch cannot import Part

Postby NormandC » Sat Mar 05, 2016 5:26 pm

bkw wrote:I'm trying to figure out what is the one degree of freedom in the sketch "cf reader holder base" in this drawing
You have a tiny and superfluous line in your sketch. The Elements list (bottom left side bar) shows all elements in your sketch, and when you click on a label, the corresponding element is highlighted kaki green in the 3D view. You will notice there is one more than it is supposed to, and nothing seems to be highlighted in the 3D view. If you tick "Extended naming", it's the one labeled "Line(Edge13)".

Delete it, and your sketch will be fully constrained.

A word of advice: for such a profile, do not use Sketcher Line, use Sketcher Polyline instead. The whole profile can be sketched in one operation, so there is reduced chance to encurr such errors as adding a tiny line by mistake.

O/T:
bkw wrote:OS: Mac OS X
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6613 (Git)
Build type: Release
Branch: (detached from 80214fb)
I'm curious to know what is that branch? The latest Ubuntu PPA daily build from last Thursday is numbered 0.16.6551.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Shake Sketch cannot import Part

Postby NormandC » Sat Mar 05, 2016 7:14 pm

NormandC wrote:I'm curious to know what is that branch? The latest Ubuntu PPA daily build from last Thursday is numbered 0.16.6551.
OK forget my question, I found out why. viewtopic.php?t=13341&start=70#p110263
bkw
Posts: 25
Joined: Tue Mar 01, 2016 12:18 am

Re: Shake Sketch cannot import Part

Postby bkw » Fri Mar 11, 2016 9:37 am

Awesome, thank you for finding that mistake line. Deleted and now contrained as you said.
Thanks for the suggestion too.
bkw
Posts: 25
Joined: Tue Mar 01, 2016 12:18 am

Re: Shake Sketch cannot import Part

Postby bkw » Fri Mar 11, 2016 9:54 am

OK not so great after all.
When I deleted that line, it screwed up the rest of the drawing. Fillet003 became invalid "no suitable edge", and Fillet012 didn't go invalid, but moved from one edge to a different nearby edge that never had a fillet on it. I can only guess that other things got corrupted as well.

Before:
https://drive.google.com/open?id=0Bys6e ... WFWcUxlZjA

After:
https://drive.google.com/open?id=0Bys6e ... nF6eXZrbEU
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Shake Sketch cannot import Part

Postby NormandC » Sat Mar 12, 2016 7:49 am

bkw wrote:Fillet003 became invalid "no suitable edge", and Fillet012 didn't go invalid, but moved from one edge to a different nearby edge that never had a fillet on it. I can only guess that other things got corrupted as well.
Indeed there were. Running the Macro ForceRecompute reveals errors in one pad, 3 sketches and one more fillet.

I'm sorry, I only replied to the original problem and didn't go further. You are a victim of the PartDesign process' Achilles' heel, what the devs and forum regulars call the topological naming problem. I won't go into detail since it's been discussed many times in the past years, here's a link that explains it but you can also search for others. viewtopic.php?t=6236
Google Summer of Code project proposal explains it in more detail: Topological Naming Project

I remember that about 2 years ago, someone created a macro that would record the state of the model before a change was applied, and running it again after the change would correct the edge/face switching. Unfortunately I did not bookmark the topic at the time nor did I save the macro, and I am now unable to retrieve the relevant topic.

You will have to rebuild your model, using the Sketcher MapSketch tool, and it's going to be a pain (I've been there more times that I can count). A word of advice: mapping sketches and building features on top of dress up features (fillets, chamfers or drafts) is very bad practice and contributes to make your model more fragile. Chamfers, fillets should almost always be applied last.