Shared parameters between sketches

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!
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Shared parameters between sketches

Post by NormandC »

Syranolic wrote:But, if we take for exemple Constraint15 (111,803mm) from the second construction sketch in "Syranolics_sword_normandc1.fcstd", can't I refer to it in profile2 instead of manually setting Constrain8?
Yes. But you need to rename it first.
  1. Edit the Construction Sketch001, then rename Constraint15 to anything, for example "Diagonal".
  2. Now the trick is to find the internal ID of "Construction Sketch001", which is only a label. You can make it visible in the 3D view, and hover your mouse over it (hide everything else to make it easier): when one of its elements is preselected and its color changes to yellow, look at the lower left of the FreeCAD window. It will be written something like
    Preselected: Syranolics_sword_normandc1.Sketch001.Edge5 (x,y,z)
    (where (x,y,z) refer to the coordinates)
    So the internal ID of this sketch is Sketch001.

    Alternatively you can go to View --> Panels and select "Selection view". Then select Construction Sketch001, and you will see this in the Selection view.
    FC_Syranolic_SelectionView_01.png
    FC_Syranolic_SelectionView_01.png (11.12 KiB) Viewed 2209 times
  3. Next, edit the Profile 2 sketch and double-click on Constraint8. In the "Insert length" dialog window, click on the f(x) Expressions icon.
    FC_Expression_Sketch_00.png
    FC_Expression_Sketch_00.png (20.12 KiB) Viewed 2209 times
  4. A new input field opens. (On my Ubuntu system, there's a bug causing the new window not to have a border.) Start typing the S letter, and auto-completion will display a list of choices. Select "Sketch001". A period is automatically appended.
    FC_Expression_Sketch_01.png
    FC_Expression_Sketch_01.png (26.4 KiB) Viewed 2209 times
  5. Now, after the period type the C letter (for "Constraints"). Auto-completion will display the only available variable, "Constraints.Diagonal". Click on it, then on OK.
    FC_Expression_Sketch_02.png
    FC_Expression_Sketch_02.png (22.82 KiB) Viewed 2209 times
  6. The Formula input closes and we get back to the "Insert length" dialog. It now shows the numerical value greyed out, and the f(x) icon is now white on blue, which shows that it is enabled. Click OK to close the dialog. The constraint is now linked.
    FC_Expression_Sketch_03.png
    FC_Expression_Sketch_03.png (19.37 KiB) Viewed 2209 times
Last edited by NormandC on Sun Jul 31, 2016 8:15 pm, edited 2 times in total.
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Shared parameters between sketches

Post by ulrich1a »

Syranolic wrote:Alternatively, it looks like I could use a few global parameters and enter mathematical expressions in the contraints. But I can't find where to define them outside of a sketch...
FreeCAD has the Spreadsheet-Workbench for this purpose: http://www.freecadweb.org/wiki/index.ph ... _Workbench
For details see here: http://www.freecadweb.org/wiki/index.ph ... xpressions

Ulrich
User avatar
Syranolic
Posts: 16
Joined: Wed Jul 20, 2016 3:32 pm
Location: Sweden
Contact:

Re: Shared parameters between sketches

Post by Syranolic »

Excellent :D
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Shared parameters between sketches

Post by ulrich1a »

As we have already two different methods to generate the spike, I want to add another but totally parametric approach. It bases on the creation of two shadow profiles.
- The shadow profiles are then padded symmetrically.
- Create a clone from each shadow profile.
- The padded profile and its clone are than turned against each other in a predetermined angle and the common of both is created.
- Do the same with the other profile and its clone.
- At last make a common of both existing commons. (This part is similar to DeepSOICs method.)

The image shows a steering sketch, which was created from the design dimensions in order to get the length marked in green. These length are used to create the shadow-profiles. An unknown angle, needed for turning of the profiles, is also delivered by the steering sketch.

I have to admit, that the padding length are manually set. In principle it should be possible to get them with some additional effort also from the steering sketch.

Ulrich

OS: Debian GNU/Linux 8.5 (jessie)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6706 (Git)
Build type: Unknown
Branch: (losgelöst von origin/releases/FreeCAD-0-16)
Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0
Python version: 2.7.9
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Attachments
Cristal_Sword.fcstd
(30.06 KiB) Downloaded 46 times
Cristal_Sword.png
Cristal_Sword.png (32.04 KiB) Viewed 2180 times
User avatar
Syranolic
Posts: 16
Joined: Wed Jul 20, 2016 3:32 pm
Location: Sweden
Contact:

Re: Shared parameters between sketches

Post by Syranolic »

Now this is well past Sketchup level :lol:

I really like how the part is created out of one essential sketch, but I don't understand its design! It's ok: I managed to draw the blade in a totally parametric fashion with 3 simple sketches now (except for the 3mm thickness).
Next I need to design the stiffeners with correct dimensions for their 3mm thickness to fit inside the blade. In case I get stuck, I suppose it's more appropriate to start a new thread instead continuing in this one, right?
Attachments
CristalSword.FCStd
(18.75 KiB) Downloaded 50 times
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Shared parameters between sketches

Post by bejant »

It's more appropriate to start a new topic for a different problem, but a few months from now if I want to find this thread I'll remember "sword" and probably "Cristal Sword" so I'd rather see this thread continued, but with the title revised as things change. That way we can also see the sword go from beginning to completion in one forum thread.

Of course, other people might have different opinions.
User avatar
Syranolic
Posts: 16
Joined: Wed Jul 20, 2016 3:32 pm
Location: Sweden
Contact:

Re: Shared parameters between sketches

Post by Syranolic »

bejant wrote:Of course, other people might have different opinions.
I'm doing both then to please everyone 8-)

I'm soon finished with the design and I could start with the tech drawings. But I still have two issues posted here:
Fully constrained, but still two alternatives?
Spreadsheet and sketch parameters: incompatible units for + operator
Post Reply