User:DeepSOIC: Difference between revisions

From FreeCAD Documentation
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
Mapping modes of the new Attacher
CompileOnWindows - reducing disk footprint


==Mode Deactivated==
Techniques to reduce disk space required for building FreeCAD on Windows
'''References:''' any
This may be of use to those, who are limited on disk space (for example, because of an SSD), and for those, who want to avoid installing complete Visual Studio.


'''Action:''' sketch remains where it was. Attachment is disabled.
==Setting up MSVC2013 compiler without installing Visual Studio==
requirements:
* another computer where complete Visual Studio is/can be installed (in theory, this can be achieved by unpacking VS installers, but there is no instructions about this here)


==Mode Translate==
===getting the compiler===
'''References:''' vertex
0. In order to get the compiler files, go to another computer and locate the actual compiler. Example of path to compiler: drive:\path\to\visual\studio\VC\bin.


'''Action:''' sketch origin is translated to coincide with the vertex. Sketch orientation doesn't change, and can be modified by changing Placement property.
1. Copy the compiler binaries and standard libraries to another computer. That is, copy the following folders to C:\Qt\msvc12rip:
* drive:\path\to\visual\studio\VC\'''bin'''
* drive:\path\to\visual\studio\VC\'''lib'''
* drive:\path\to\visual\studio\VC\'''include'''


[[image:Attacher_mode_Translate.png|250px]]
2. Install [https://msdn.microsoft.com/en-us/windows/desktop/bg162891.aspx Windows SDK]. For those who don't know, it is a set of headers, libs and tools to compile Windows programs. Note, where it is installed to. Example path: C:\Program Files (x86)\Windows Kits\8.1


3. Install CMake and Qt creator (just the creator, i.e. the environment, not the actual Qt, to save space).


==Mode ObjectXY==
4. Set up a custom compiler in Qt Creator. Read on to see how.
'''References:''' object


'''Action:''' sketching plane is XY plane of object's local coordinate system (according to its Placement property).
===compiler in Qt Creator===
====32-bit====
Setting the compiler for 32 bit is quite straightforward.
4.1. Set up the compiler under Compilers tab in settings: Add a '''custom''' compiler:
* name = msvcrip (the name doesn't matter, it is up to you)
* Compiler path: C:\Qt\msvc12rip\VC\bin\cl.exe
* Make path: C:\Qt\msvc12rip\VC\bin\nmake.exe
* ABI: x86-windows-msvc2013-pe-32bit
* header paths - nothing
* error parser: MSVC
[[image:Msvc-no-vs_compiler-setup-32.png|600px]]


[[image:Attacher_mode_ObjectXY.png|250px]]
4.2. Under kits tab, I added a kit, and set it up like this:
* name: FreeCAD32 (again, up to you)
* Device type: Desktop
* Device: Local PC
* Compiler: msvcrip (or whatever you named it in step 1)
* Environment: (correct the paths to your setup)
{{code|code=
INCLUDE=C:\Program Files (x86)\Windows Kits\8.1\Include\um\;C:\Qt\msvc12rip\VC\include\
LIB=C:\Qt\msvc12rip\VC\lib\;C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\
LIBPATH=C:\Qt\msvc12rip\VC\lib\;C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86\
PATH=C:\Qt\msvc12rip\VC\bin\;C:\Program Files (x86)\Windows Kits\8.1\bin\x86\;C:\Qt\git\bin\}}
Note the path to git.exe in PATH. It is optional, but if not specified, the version info will be incomplete in FreeCAD's About.
* Debugger: (optional) set to 32-bit (x86)
* Qt version: None
[[image:Msvc-no-vs_kit-setup-32.png|600px]]


The environment part of the settings took me the most trouble to configure


====64-bit====
==Mode ObjectXZ==
'''References:''' object
This is a little bit more tricky than 32-bit compiler. The main problem was that there is no nmake executable in C:\Qt\msvc12rip\VC\bin\'''x86_amd64''', and nmake keeps using the 32-bit compiler. To counter the problem, create a special folder "C:\Qt\msvc12rip\VC\bin\'''x86_amd64_sa'''", where mnake and 64-bit cl are combined. Read on for step-by-step instructions.


'''Action:''' like ObjectXY.
4.1. in C:\Qt\msvc12rip\VC\bin, create a folder named '''x86_amd64_sa''' (sa stands for Stand-Alone, use whatever name you like).


[[image:Attacher_mode_ObjectXZ.png|250px]]
4.2. copy contents of folder C:\Qt\msvc12rip\VC\bin into x86_amd64_sa folder (now you have a 32-bit compiler there)


4.3. copy contents of folder x86_amd64 into x86_amd64_sa, replacing files in the process. Now you have a 64bit compiler with nmake there.


==Mode ObjectYZ==
4.4. Set up the compiler under Compilers tab in settings: Add a '''custom''' compiler:
'''References:''' object
* name = msvcrip'''64''' (the name doesn't matter, it is up to you)
* Compiler path: C:\Qt\msvc12rip\VC\bin\x86_amd64_sa\cl.exe
* Make path: C:\Qt\msvc12rip\VC\bin\x86_amd64_sa\nmake.exe
* ABI: x86-windows-msvc2013-pe-'''64bit'''
* header paths - nothing
* error parser: MSVC


'''Action:''' like ObjectXY.
4.5. Under kits tab, I added a kit, and set it up like this:
* name: FreeCAD'''64''' (again, up to you)
* Device type: Desktop
* Device: Local PC
* Compiler: msvcrip'''64''' (or whatever you named it in step 4.4)
* Environment: (correct the paths to your setup) (compared to 32-bit, amd64/x64 has appeared or has replaced x86 in several places)
{{code|code=
INCLUDE=C:\Program Files (x86)\Windows Kits\8.1\include\shared\;C:\Program Files (x86)\Windows Kits\8.1\include\um\;C:\Qt\msvc12rip\VC\include
LIB=C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64\;C:\Qt\msvc12rip\VC\lib\amd64\
LIBPATH=C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\
PATH=C:\Qt\msvc12rip\VC\bin\x86_amd64_sa\;C:\Program Files (x86)\Windows Kits\8.1\bin\x64\;C:\Qt\git\bin\}}
Note the path to git.exe in PATH. It is optional, but if not specified, the version info will be incomplete in FreeCAD's About.
* Debugger: (optional) set to '''64'''-bit (x64)
* Qt version: None


[[image:Attacher_mode_ObjectYZ.png|250px]]
Tip: set up another kit+compiler pair for using jom instead of nmake, to enable multicore build. The configuration is identical to 64-bit with nmake, except that Make in compiler tab should point to jom.exe. Example path to jom: C:\Qt\Qt542\Tools\QtCreator\bin\jom.exe (you should be able to find jom under where your Qt creator is installed).


===testing compiler and building FreeCAD===
All the rest is identical to the normal way one would compile FreeCAD:


==Mode FlatFace==
Open FreeCAD (CMakeLists.txt) with Qt creator, and it will invite you to run cmake. Run it. '''CMake will build a test program, to see if the compiler works.''' If the compiler doesn't work, it will show an error telling exactly that, and listing the build output. This should help you identify, what's going wrong. Here is a small list of typical errors:
'''References:''' face or plane
* ''Can't open Kernel32.lib'' - something's wrong with LIB or LIBPATH environment variables (note: they set under kits tab in Qt, not in windows!)
* ''Can't resolve external symbol'' - something's wring with LIB or LIBPATH (they probably point to .lib-s of wrong bit-ness)
* ''Manifest-related error'' - PATH does not point to a location where a resource compiler (rc.exe) of right bit-ness is located.
* ''Can't locate include'' - the include location list should contain path to standard headers (C:\Qt\msvc12rip\VC\include on my machine)


'''Action:''' legacy. Sketching on a flat face.
To run FreeCAD built with type "Debug", debug versions of MSVC2013 redistributable libraries (msvcp120d.dll, msvcr120d.dll) must be present somewhere reacheable through PATH (system-wide, this time).


[[image:Attacher_mode_FlatFace.png|250px]]
You can obtain these dlls from the other computer that has the Visual Studio you ripped the compiler off. Alternatively, these dlls can be extracted from visual studio installer directly, which is very easy:
* mount the downloaded .iso image as a disk (drive D: on my system)
* locate the files:
** D:\packages\vc_librarycore86\cab3.cab/F_REDIST_DLL_APPLOCAL_'''msvcp120d_x64''' (<- or x86, if you are building 32-bit)
** D:\packages\vc_librarycore86\cab3.cab/F_REDIST_DLL_APPLOCAL_'''msvcr120d_x64'''
* extract the files, and name them "msvcp120d.dll", "msvcr120d.dll"
* copy the files to libpack folder, into bin


==avoiding copying any libpack files to launch FreeCAD==
The idea is very simple: instead of copying files - make links. On Windows, there are symbolic links to files. A link makes the linked file appear to be where the link is, but the file is actually stored somewhere else. Links can be made using batch command '''[https://technet.microsoft.com/en-us/library/cc753194(v=ws.10).aspx mklink]'''.


==Mode TangentPlane==
Since there are way too many files to make links manually, a batch script should be used. Here is an example of such a script:
'''References:''' face+vertex or vertex+face


'''Action:''' sketching plane is tangent to surface of face at the point on the surface that is closest to the vertex. If vertex is linked in first, the plane is translated to go through the vertex. If face is first, the plane touches the surface. X axis of sketch is chosen to go along internal face's parametrization.
links_libpack.bat:{{code|code=
@set libpackpath=C:\_vt\dev\PC\Qt\FreeCAD\libpack\active
@set builddir=%1
pushd %libpackpath%\bin
for %%i in (*) do mklink "%builddir%\bin\%%i" "%libpackpath%\bin\%%i"
for /D %%s in (*) do mklink /d "%builddir%\bin\%%s" "%libpackpath%\bin\%%s"
popd
pause
}}
First for loop creates links to files, the second loop - links to folders.<br>
You'll have to modify the path to libpack to match yours. Use absolute paths. Then, feed FreeCAD build folder path (full path!) to the script as an argument.


[[image:Attacher_mode_TangentPlane.png|250px]]
This batch must be run with administrator privileges (or, you can set to allow users use mklink in local security policy settings in Windows). The batch may fail, if there are spaces in paths (it may work, but it is untested). Tip: create a shortcut to links_libpack.bat, set it up to run as admin (in shortcut properties), and drag the build folder onto the shortcut.


==Mode NormalToEdge==
'''References:''' edge or edge+vertex or vertex+edge

'''Action:''' sketching plane is normal to the edge at the point of the edge's curve that is closest to the vertex (or defined by MapPathParameter property, if vertex is not linked). The origin of sketch is translated to the vertex if the virtex is first, or kept at where the curve pierces the sketch plane if edge is first. X axis of sketch is chosen automatically.

[[image:Attacher_mode_NormalToEdge.png|250px]]


==Mode FrenetNB==
'''References:''' curved edge OR curved edge+vertex OR vertex+curved edge

'''Action:''' sketching plane is normal-binormal (NB) axes of Frenet-Serret coordinates at the point of the edge's curve that is closest to the vertex (or defined by MapPathParameter property, if vertex is not linked). The origin of sketch is translated to the vertex if the vertex is first, or kept at the curve if edge is first. This mode is similar to NormalToEdge, except that X axis is well-defined.

[[image:Attacher_mode_FrenetNB.png|250px]]


==Mode TrenetTN==
'''References:''' curved edge OR curved edge+vertex OR vertex+curved edge

'''Action:''' sketching plane is tangent-normal (TN) axes of Frenet-Serret coordinates at the point of the edge's curve that is closest to the vertex (or defined by MapPathParameter property, if vertex is not linked). The origin of sketch is translated to the vertex if the vertex is first, or kept at the curve if edge is first. Effectively, if the curve is planar, the sketching plane is the plane of the curve.

[[image:Attacher_mode_FrenetTN.png|250px]]


==Mode FrenetTB==
'''References:''' curved edge OR curved edge+vertex OR vertex+curved edge

'''Action:''' sketching plane is tangent-binormal (TB) axes of Frenet-Serret coordinates at the point of the edge's curve that is closest to the vertex (or defined by MapPathParameter property, if vertex is not linked). The origin of sketch is translated to the vertex if the vertex is first, or kept at the curve if edge is first.

[[image:Attacher_mode_FrenetTB.png|250px]]


==Mode Concentric==
'''References:''' curved edge OR curved edge+vertex OR vertex+curved edge

'''Action:''' same as FrenetTN, but sketch origin is placed at the center of curvature of the edge.

[[image:Attacher_mode_Concentric.png|250px]]


==Mode SectionOfRevolution==
'''References:''' curved edge OR curved edge+vertex OR vertex+curved edge

'''Action:''' same as FrenetNB, but sketch origin is placed at the center of curvature of the edge, and Y axis is the axis of osculating circle. Useful to make grooves on bodies of revolution.

[[image:Attacher_mode_SectionOfRevolution.png|250px]]


==Mode ThreePointsPlane==
'''References:''' vertex+vertex+vertex or line+vertex or vertex+line or line+line

'''Action:''' sketching plane goes through three vertices defined by references. Line is treated as if it is two vertices.

[[image:Attacher_mode_ThreePointsPlane.png|250px]]


==Mode ThreePointsNormal==
'''References:''' vertex+vertex+vertex or line+vertex or vertex+line or line+line

'''Action:''' sketching plane contains first two vertices, and is normal to the plane defined by three vertices.

[[image:Attacher_mode_ThreePointsNormal.png|250px]]


==Mode Folding==
'''References:''' line+line+line+line

'''Action:''' specialty mode to fold polyhedra. See picture. It is required that all four lines share an endpoint. It is not required that both leafs to fold together are the same, like on the picture.

[[image:Attacher_mode_Folding.png|250px]]

Latest revision as of 17:21, 1 July 2015

Mapping modes of the new Attacher

Mode Deactivated

References: any

Action: sketch remains where it was. Attachment is disabled.

Mode Translate

References: vertex

Action: sketch origin is translated to coincide with the vertex. Sketch orientation doesn't change, and can be modified by changing Placement property.


Mode ObjectXY

References: object

Action: sketching plane is XY plane of object's local coordinate system (according to its Placement property).


Mode ObjectXZ

References: object

Action: like ObjectXY.


Mode ObjectYZ

References: object

Action: like ObjectXY.


Mode FlatFace

References: face or plane

Action: legacy. Sketching on a flat face.


Mode TangentPlane

References: face+vertex or vertex+face

Action: sketching plane is tangent to surface of face at the point on the surface that is closest to the vertex. If vertex is linked in first, the plane is translated to go through the vertex. If face is first, the plane touches the surface. X axis of sketch is chosen to go along internal face's parametrization.


Mode NormalToEdge

References: edge or edge+vertex or vertex+edge

Action: sketching plane is normal to the edge at the point of the edge's curve that is closest to the vertex (or defined by MapPathParameter property, if vertex is not linked). The origin of sketch is translated to the vertex if the virtex is first, or kept at where the curve pierces the sketch plane if edge is first. X axis of sketch is chosen automatically.


Mode FrenetNB

References: curved edge OR curved edge+vertex OR vertex+curved edge

Action: sketching plane is normal-binormal (NB) axes of Frenet-Serret coordinates at the point of the edge's curve that is closest to the vertex (or defined by MapPathParameter property, if vertex is not linked). The origin of sketch is translated to the vertex if the vertex is first, or kept at the curve if edge is first. This mode is similar to NormalToEdge, except that X axis is well-defined.


Mode TrenetTN

References: curved edge OR curved edge+vertex OR vertex+curved edge

Action: sketching plane is tangent-normal (TN) axes of Frenet-Serret coordinates at the point of the edge's curve that is closest to the vertex (or defined by MapPathParameter property, if vertex is not linked). The origin of sketch is translated to the vertex if the vertex is first, or kept at the curve if edge is first. Effectively, if the curve is planar, the sketching plane is the plane of the curve.


Mode FrenetTB

References: curved edge OR curved edge+vertex OR vertex+curved edge

Action: sketching plane is tangent-binormal (TB) axes of Frenet-Serret coordinates at the point of the edge's curve that is closest to the vertex (or defined by MapPathParameter property, if vertex is not linked). The origin of sketch is translated to the vertex if the vertex is first, or kept at the curve if edge is first.


Mode Concentric

References: curved edge OR curved edge+vertex OR vertex+curved edge

Action: same as FrenetTN, but sketch origin is placed at the center of curvature of the edge.


Mode SectionOfRevolution

References: curved edge OR curved edge+vertex OR vertex+curved edge

Action: same as FrenetNB, but sketch origin is placed at the center of curvature of the edge, and Y axis is the axis of osculating circle. Useful to make grooves on bodies of revolution.


Mode ThreePointsPlane

References: vertex+vertex+vertex or line+vertex or vertex+line or line+line

Action: sketching plane goes through three vertices defined by references. Line is treated as if it is two vertices.


Mode ThreePointsNormal

References: vertex+vertex+vertex or line+vertex or vertex+line or line+line

Action: sketching plane contains first two vertices, and is normal to the plane defined by three vertices.


Mode Folding

References: line+line+line+line

Action: specialty mode to fold polyhedra. See picture. It is required that all four lines share an endpoint. It is not required that both leafs to fold together are the same, like on the picture.