Macro Half-Hull Model

From FreeCAD Documentation
Jump to navigation Jump to search
This page is a translated version of the page Macro Half-Hull Model and the translation is 19% complete.
Other languages:
English • ‎français • ‎italiano

Macro Half Hull Model.png Macro Half-Hull Model

Description
Cette macro génère une forme en trois dimensions d'une demi-coque et pleine coque avec une série de dessins en 2 dimensions.

Version macro : 1.0
Date dernière modification : 2016-01-25
Version FreeCAD : <= 0.16
Téléchargement : ToolBar Icon
Auteur
Piffpoof
Téléchargement
ToolBar Icon
Liens
Version Macro
1.0
Dernière modification
2016-01-25
Version(s) FreeCAD
<= 0.16
Raccourci clavier
None
Voir aussi
None


Description

Cette macro crée un une forme simple de coques de bateaux et navires. Il est destiné à aider les personnes modélisant une coque en fournissant les sections de coupes de la coque d'une manière directe afin qu'ils puissent éviter le fastidieux processus complet.

Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager.


# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.

from PySide import QtGui, QtCore

diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
    "Information",
    "This macro must be downloaded from this link\n"
    "\n"
    "http://pastebin.com/raw/tZMpUi6F" + "\n"
    "\n"
    "Quit this window to access the download page")

diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()

import webbrowser 
webbrowser.open("http://pastebin.com/raw/tZMpUi6F")
<class="rawcodeurl"><a href="http://pastebin.com/raw/tZMpUi6F">raw code</a>


Macro Half-Hull ModelScreenBoatInABottle.jpg

Contexte

Depuis l'Antiquité, les constructeurs de bateaux ont dû concevoir des bateaux puis les réaliser dans un environnement tridimensionnel où très peu de lignes sont droites, très peu de surfaces plates et où aucun angle n'est constant. Les modèles de coque ont été utilisés pour créer des modèles à l'échelle qui pourraient ensuite être utilisés pour revoir la conception ou communiquer les concepts à d'autres personnes. Les lois de l'hydrodynamique exigent que tout navire traversant un liquide ait une section symétrique s'il veut suivre (se déplacer en ligne droite) avec précision. Par conséquent, il ne suffisait que de construire un côté de la coque dans le modèle. Si la demi-coque était parfaite, son image en miroir le serait également. Au cours des dernières années, les demi-coques ont été utilisées à des fins symboliques telles que les plaques et l'art nautique.

Ce code est issu d'un projet de construction d'un modèle de bateau à voile de 12,5 mètres sous FreeCAD. Les constructeurs n'avaient plus de dessins et le fils du propriétaire initial doutait qu'il y ait jamais eu de dessins complets. Par conséquent, les dimensions de la coque ont dû être mesurées, puis un modèle construit dans le logiciel. Les progiciels modernes tels que FreeCAD offrent de nombreuses fonctionnalités avantageuses telles que les contraintes de symétrie, mais lorsque la mesure finale est un modèle "facile à regarder". Ce code a été écrit pour aider à automatiser ce processus.

Le but initial de ce code était de fournir une coque symétrique qui était malléable afin de pouvoir être adaptée au modèle 3D en cours de construction. Au fur et à mesure que le logiciel progressait, il a été généralisé, donc j'espère qu'il serait utile aux personnes:

  • concepteurs de bateaux produisant des schémas de bateaux qui peuvent être construits à partir de
  • constructeurs de bateaux qui tentent de modéliser ce qui est décrit sur leurs schémas
  • constructeurs de coques modèles.

Certes, les concepteurs de bateaux commerciaux ont toutes sortes de logiciels haut de gamme pour faciliter leur travail, cela n'est pas censé remplacer cela. C'est plutôt pour l'amateur ou le constructeur de maisons de bricoler.

Les plans nautiques ont une histoire distincte en ce qui concerne les bâtiments et sont donc quelque peu différents dans leur présentation. Voici un exemple de voilier vieux de plus d'un siècle:

Macro Half-Hull ModelImage0.jpg

L'un des objectifs finaux de ce logiciel est d'utiliser l'atelier Draft pour générer certains de ces diagrammes en utilisant le modèle pour générer les lignes.

Remarque sur les unités dans FreeCAD:

À l'heure actuelle, il n'y a pas vraiment de système de gestion des unités au sein de FreeCAD, mais évidemment, un constructeur de bateaux ou un modélisateur aura besoin d'un système de dimensionnement précis. Pour utiliser cette macro, décidez de définir la taille de la grille FreeCAD sur ce qui est toujours approprié pour votre travail (par exemple mm, cm, pouces, pied). FreeCAD est cohérent, une unité FreeCAD sera constamment égale à une unité FreeCAD. Et si vous avez décidé d'avoir une unité FreeCAD égale à une longueur physique spécifique, vos dessins resteront dimensionnés de manière cohérente. Actuellement, des travaux sont en cours sur un système d'unités pour FreeCAD, de sorte que cette situation pourrait bientôt changer.

Description

Pour cette macro, les formes de coque sont définies par au moins 3 esquisses FreeCAD: une dans le plan YZ, une ou plusieurs dans le plan XZ, une dans le plan XY. Voici la coque minimum supportée par cette macro, elle ne dispose que de 3 croquis:

Macro Half-Hull ModelImage1.jpg

Remarque: dans le diagramme ci-dessus, nous regardons directement à l'arrière, la proue pointe loin du point de vue.

De l'avant vers l'arrière (de l'arc à la poupe), les 3 croquis sont:

ligne d'étrave
plan YZ
ligne rouge dans le croquis
coupe transversale
plan XZ
ligne verte dans le croquis
tableau arrière
plan XY
ligne bleue dans le croquis


Perhaps it is easier to see with 7 Sketches (one in YZ plane, one in XY plane and 5 in the XZ plane):

Macro Half-Hull ModelImage2.jpg

With 5 Sketches in the XZ plane it is becoming easier to perceive the shape of the hull. The next 2 pictures show the Sketch lines superimposed on the model FreeCAD constructs,

Macro Half-Hull ModelImage3.jpg

the second is the same model rotated 90 degrees so the bow is in the foreground:

Macro Half-Hull ModelImage3a.jpg

Some points to consider:

  • the Sketches are only for:
    • the stemline (or bow line) in the YZ plane (red in the above diagram);
    • the top of the transom in the XY plane (blue in the above diagram);
    • multiple cross-sections of the hull in the XZ plane (green in the above diagram)
  • only the starboard side of the hull is drawn in the Sketches, the port side will be generated as a mirror image
  • each multiple-segment line must be in a separate Sketch
  • each Sketch must have the same number of line segments (which is 3 in the previous examples)
  • the more line segments in each Sketch, the closer the FreeCAD generated model will approximate a curved hull
  • there is no limit to the number of line segment in each Sketch, any number from one up
  • there is no limit to the number of Sketches in the XZ plane (i.e. cross-sections), any number from one up

With enough Sketches the model generated may even approach:

Macro Half-Hull ModelImage4.jpg

The HalfHull macro generates 4 models:

  • starboard half-hull
  • port half-hull
  • complete hull
  • bulkheads for the complete hull, either with a flush deck or with a coachhouse

These models are all output in the unified location space of FreeCAD so they can be fitted together - for example the bulkheads can be inserted into the complete hull seamlessly. This is a picture of bulkheads in a boat model during construction:

Macro Half-Hull ModelImage5.jpg

As well as the bulkheads generated by the macro (note that these bulkheads are for a coachhouse rather than a flush deck):

Macro Half-Hull ModelImage6.jpg

The composite image below shows the main outputs from this software (the port side half-hull is actually not shown but it is the mirror of the starboard half-hull which is shown). The outputs are in clockwise order from the upper left corner:

  • starboard half-hull
  • complete hull
  • bulkheads (for flush deck, the bulkheads in the previous image were for a coachhouse deck)
  • the complete hull with the bulkheads inserted

Macro Half-Hull ModelImage7.jpg

As novelty features, the macro will also optionally produce plaques for the half-hulls, and even a bottle for the complete hull:

Macro Half-Hull ModelImage8.jpg

Macro Half-Hull ModelImage9.jpg

Installation

All the code for halfHullModel.FCMacro is in one macro. So installation is comprised of copying the code to the appropriate Macro directory and invoking the Build Utility from the Macro menu, the Python console or a toolbar button (the preferred method).

Usage

The FreeCAD operations involved in generating the hull model are rather complex and numerous. Things like the direction a line is drawn can cause the FreeCAD construction of the hull to either abort or turn out like:

Macro Half-Hull ModelUsage1.jpg

Consequently the steps below need to be followed closely. The macro does allow for certain data inconsistencies but generally if the data (i.e. the Sketches) are incorrect then the output will look like a cheese grater or the macro fill fail with an error.

The following instructions refer to the quadrants of the XY graph, this refers to the 4 quarters of the XY graph and they are labelled as follows:

Macro Half-Hull ModelUsage2.jpg

Create a New Document

The very first thing is to create a new document in FreeCAD Document-new.svg. This document will hold all the Sketches that make up your hull definition.

Create the Stemline

The first step is one of creating data for the hull model to be made from. The data is supplied in the form of Sketches within FreeCAD. After the hull model is generated, if changes are to be made then the Sketches are simply edited, and the second step of running the macro repeatedly.

  1. create a new sketch Sketcher NewSketch.svg, in the YZ-Plane
  2. start at origin (0,0) and draw upwards into Quadrant I
    Macro Half-Hull ModelUsage3.jpg
  3. the bottom end of the stemline is at the origin (0,0) - this will be the point from where the placement of all the cross-sections and transom will be made
  4. the number of line segments in this Sketch determines the number which will be required in each other Sketch
  5. save sketch Sketcher LeaveSketch.svg
  6. for ease of identification it is probably worth naming the Sketch something like "stemline sketch"

Create the Cross-section Sketch(es)

  1. create a new sketch Sketcher NewSketch.svg, in the XZ-Plane
  2. the following dialog will appear:
    Macro Half-Hull ModelScreenSnapshot1.jpg
    The dialog is asking how far from the origin the Sketch should be placed. This will refer to how far the cross-section is from the bottom of the stemline (which was placed at (0,0)). The cross-sections can be equally spaced but need not be. The forward-most cross-section will be at Y=0 (i.e. the origin where the stemline bottom ends) or at Y<=0. The cross-sections will be at increasingly negative Y values until the transom is at the most negative Y value. In the example above, the cross-section Sketch will be placed 50 FreeCAD units from the origin on the negative Y axis.
  3. start on the Y axis and draw upwards into Quadrant I
    - the first (i.e. foremost) cross-section should start at origin (0,0) (or it will look odd as the stemline ends at 0,0) but other cross-sections need only start on the Y axis.
    Macro Half-Hull ModelUsage3.jpg
  4. use the same number of line segments as in the Stemline Sketch
  5. save sketch Sketcher LeaveSketch.svg
  6. repeat as this step necessary, it may be quicker to copy this sketch and then space the copies on the Y-axis, modifications may be made to the individual Sketches as required
  7. for naming, it will make things easier to give some sort of sequence to the cross-sections, starting at the bow (i.e. the stemline) and increasing towards the stern (i.e. the transom)

Create the Transom Sketch in the XY Plane

  1. create a new sketch Sketcher NewSketch.svg, in the XY-Plane
  2. start on the Y axis between quadrant III and IV, and draw upwards into Quadrant IV so that the end point is coincident with the rightmost point of the lowest cross-section Sketch in the YZ-plane
    Macro Half-Hull ModelUsage4.jpg
  3. use the same number of line segments as in the stemline Sketch
  4. save sketch Sketcher LeaveSketch.svg
  5. for ease of identification it is probably worth naming the Sketch something like "transom sketch"

Save the New Document

Now save the document Document-save.svg which contains the Sketches that will define the hull shape, giving it some name that is descriptive

Once the Sketches have all been created and positioned, the document should look like this from the top view View-top.svg:

Macro Half-Hull ModelUsage5.jpg

The principal limitations for constructing the model are:

  • the stemline bottom should end at (0,0)
  • the bottom centremost end of each cross-section should end at the Y axis - note that it can have any Z value

This concludes the first step which is one of creating the data which the macro will use to create both half-hulls and complete-hulls. The second step is described in the following section which is titled User Interface

User Interface

In this step the macro will gather some information from the user and then process the input Sketches to generate the desired hull models. This is the only GUI image for the macro and is primarily configuration details for the production of the hull models from the Sketches:

Macro Half-Hull ModelScreenSnapshot2.jpg

The choices on the GUI window are:

  • Starboard half-hull
    - checking this will cause the macro to produce a starboard half-hull model
    • Mounting plaque
      - if checked the macro will mount the half-hull on a plaque
      • Allow space for keel
        - if checked will cause the half hull to be mounted higher on the plaque than the centre position, this is so a separately generated keel could be placed below the hull
  • Port half-hull
    - checking this will cause the macro to produce a port half-hull model
    • Mounting plaque
      - if checked the macro will mount the half-hull on a plaque
      • Allow space for keel
        - if checked will cause the half hull to be mounted higher on the plaque than the centre position, this is so a separately generated keel could be placed below the hull
  • Complete hull
    - checking this will cause the macro to produce a complete model
    • Bottle for complete hull
      - if checked the macro will place the complete hull inside a transparent bottle (complete with cork)
      • Allow space for keel
        - if checked will cause the half hull to be positioned higher in the bottle than the centre position, this is so a separately generated keel could be placed below the hull
  • Bulkheads for flush deck
    - checking this will cause the macro to produce bulkheads whose tops are level with the top of the hull, bulkheads will not be generated for the most forward 2 cross-sections or the aft-most 2 cross-sections
  • Bulkheads for coachhouse
    - checking this will cause the macro to produce bulkheads whose tops are possibly above the top of the hull.
    • Bulkheads to skip at bow determines how many cross-sections will be left without a bulkhead at the bow
    • Bulkheads to skip at stern determines how many cross-sections will be left without a bulkhead at the stern
  • The dimensions of the top of the bulkheads will be configured as per the following diagram:
    Macro Half-Hull ModelUi1.jpg
  • Cancel button
    - the execution is halted and the window closes
  • Re-Use Last File button
    - the execution uses the data file AND SETTINGS from the the last run, any changes to settings are ignored
  • Select File button
    - the standard Open File window is opened where the user can either select a file or Cancel and exit

When the macro runs it takes configuring data from the user and then reads Sketcher sketches in the selected input file.

Note: As the macro works through the Sketches it prints out any exceptions as well as some milestones on the Report View. If you get unexpected results or some parts are missing, that is probably the first place to check.

Options

There are various types of bows and sterns for boats, with sterns having much more variety than bows. Here are examples of transoms and bows from the real world alongside the similar macro output:

Sheer Stern

Probably the most common stern, typical of all sizes of vessels from commercial ships through to rowing boats.

Macro Half-Hull ModelOption1.jpg Macro Half-Hull ModelOption2.jpg
  • the XY transom should be as close to the aftmost cross-section as is possible.

Sugar-Scoop Stern

Most likely to be found on a sailing yacht, it is a product of designing to maximise the length of the waterline to benefit from class rules for racing under sail.

Macro Half-Hull ModelOption3.jpg Macro Half-Hull ModelOption4.jpg
  • place the aftmost 2 cross-sections as close as is feasible, then rotate the aftmost of the two through to an angle of 45 degrees (or whatever is called for) around the X-axis

Canoe Stern

Found on all sizes of water craft, power and sail, pleasure and commercial.

Macro Half-Hull ModelOption5.jpg Macro Half-Hull ModelOption6.jpg
  • place the aftmost 2 cross-sections as close as is feasible, then rotate the aftmost of the two through to an angle of 45 degrees around the X-axis

Normal Bow

There is a lot less variety in bow shapes than with transoms:

Macro Half-Hull ModelOption7.jpg Macro Half-Hull ModelOption8.jpg

Trireme Bow

Although not seen very frequently in the last 2 millenia, this was once the definitive bow profile for war-making vessels:

Macro Half-Hull ModelOption9.jpg Macro Half-Hull ModelOption10.jpg
  • in order for the bow to be correct the poly-line for the stemline needs to be drawn from the bottom to the top which will mean right to left in the Sketcher

Sample Files

These files are samples of Sketch data to use with the macro, mainly they are the models for the screen snapshots in the Options section above. The files work with the Macro and so can be downloaded and played with to adapt to your specific requirements. The prefix of 5x3 (for example) means the model has 5 cross-sections and 3 line segments per cross-section (i.e. sketch)

To use one of the example files, right-click on the file link and select Save File As... from the menu. The filename will be specified, choose the desired folder/directory to hold the example file.

Remarks

  • almost all the examples on this page are generated with only 3 line segments defining the side of the hull which gives a very faceted appearance, increasing the number of segments in each Sketch would generate a much smoother surface which would increase the realism
  • doesn't do keels, skegs or rudders, in other words, it doesn't do any of the wet area
  • doesn't do square bows like push-boats or towed barges
  • doesn't do submarines (although it will do the lower half of a submarine)

Known Problems

The 'Ruled Surface' feature of FreeCAD is used to generate the hull sections from the Sketches. It can sometimes generate the wrong result and display a grater like surface instead of a smooth planar one. This will typically occur when the Sketches are rotated such as when a Sugar Scoop stern is modeled. Also angling a Sheer Transom stern can cause this. If it occurs then typically it will do so in either the half-hull models or the complete hull model - it never seems to occur in all three models for the same hull. Also it usually only happens at the extreme bow or stern. If it happens to section in the middle of the boat then most likely one of the Sketches was drawn in the wrong direction (i.e. either random sequence or top-down where as all lines should be drawn bottom-up)

It can usually be removed by using the following steps:

  • in the Model tab of the Combo View, click on the faulty segment to select it, the faulty segment will show as highlighted on the display
  • select the Data tab on the bottom half of the Combo View, the lower part of the window will have a Label "Ruled Surface" with a single parameter 'Orientation'
  • there is a popup menu to the right which has the values 'Automatic', 'Forward', 'Reversed', it will initially be set to 'Automatic'
  • try one of the other settings (remembering the faulty segment must still be selected in the upper part of the Combo View) which will usually correct the problem

The following screen snapshot shows the relevant portion of the screen:

Macro Half-Hull ModelKnownProblems1.jpg

Future Possibilities

  • replace line segments of cross-sections with curved lines
    - this is just at the idea stage but would give a much smoother surface in the vertical dimension, however the horizontal surface would still be faceted as it is now
  • integrate with Draft workbench to produce drawings from models
    - an initial goal, but the feasibility has not been investigated
  • handle keels, skegs and rudders
    - one work around for keels with the present system is to model the keel as a half-hull on it's own and then assemble it onto the bottom of the main hull; this would still do nothing for rudders and skegs though

Glossary

As with any ancient and practiced trade, a rich and sometimes confusing vocabulary has developed around ships, boats and nautical practices. In describing this macro it is both awkward and inefficient to describe the process without using the correct and accurate terms. The obvious problem is that the average lay person will be unfamiliar with such terminology, hence this vocabulary:

aft the rear aspect of anything on a boat


chine a planar facet of a hull, can be used to approximate a curved surface or as a finished building technique


coachhouse the part of the central deck which is raised above the deck level - usually to accommodate increased headroom in the interior of the boat


flush deck a deck that runs smoothly from the top of one side of the hull to the other, the converse to a coachhouse deck


forward also 'fore'; the front aspect of anything on a boat


port lefthand side looking forward


starboard righthand side looking forward


stemline the sloped vertical edge which is the bow of a hull


transom the curved top edge of the stern face which can be flat or curved

Links

Script

ToolBar Icon Macro Half Hull Model.png

Macro_Half_Hull_Model.FCMacro

This script is running bug free. But due to the large range of possible inputs it may fail for some inputs. If so please report it.

The script is too long for the Wiki to display so it must be copied or downloaded from unabbreviated script on pastebin.com