[TechDraw] Collect doc info to fill template fields

This commit is contained in:
Syres916
2023-12-07 22:41:25 +00:00
committed by WandererFan
parent ba236d0b94
commit c81435c615
9 changed files with 1135 additions and 1 deletions

View File

@@ -897,6 +897,7 @@
<FCText Name="TechDraw_ExtensionVertexAtIntersection"></FCText>
<FCText Name="TechDraw_ExtentGroup"></FCText>
<FCText Name="TechDraw_FaceCenterLine"></FCText>
<FCText Name="TechDraw_FillTemplateFields"></FCText>
<FCText Name="TechDraw_GeometricHatch"></FCText>
<FCText Name="TechDraw_Hatch"></FCText>
<FCText Name="TechDraw_HoleShaftFit"></FCText>

View File

@@ -21,10 +21,12 @@ set(TechDraw_ToolsScripts
TechDrawTools/CommandMoveView.py
TechDrawTools/CommandShareView.py
TechDrawTools/CommandAxoLengthDimension.py
TechDrawTools/CommandFillTemplateFields.py
TechDrawTools/CommandVertexCreations.py
TechDrawTools/CommandHoleShaftFit.py
TechDrawTools/TaskMoveView.py
TechDrawTools/TaskShareView.py
TechDrawTools/TaskFillTemplateFields.py
TechDrawTools/TaskHoleShaftFit.py
TechDrawTools/TaskAddOffsetVertex.py
TechDrawTools/TDToolsUtil.py
@@ -42,6 +44,10 @@ SET(TechDraw_PATFile
PAT/FCPAT.pat
)
SET(TechDraw_CSVFile
CSVdata/FillTemplateFields.csv
)
SET(TechDraw_LineGroupFile
LineGroup/ANSI.Y14.2M.1992.ElementDef.csv
LineGroup/ANSI.Y14.2M.1992.LineDef.csv
@@ -53,7 +59,7 @@ SET(TechDraw_LineGroupFile
)
add_custom_target(TechDraw_Data ALL
SOURCES ${TechDraw_Scripts} ${TechDraw_PATFile} ${TechDraw_LineGroupFile} ${TechDraw_ToolsScripts} ${TechDraw_ToolsGui}
SOURCES ${TechDraw_Scripts} ${TechDraw_PATFile} ${TechDraw_CSVFile} ${TechDraw_LineGroupFile} ${TechDraw_ToolsScripts} ${TechDraw_ToolsGui}
)
fc_target_copy_resource(TechDraw_Data
@@ -67,6 +73,11 @@ fc_target_copy_resource(TechDraw_Data
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw
${TechDraw_PATFile})
fc_target_copy_resource(TechDraw_Data
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw
${TechDraw_CSVFile})
fc_target_copy_resource(TechDraw_Data
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw
@@ -97,6 +108,15 @@ INSTALL(
PATTERN "*.pat*"
)
INSTALL(
DIRECTORY
CSVData
DESTINATION
${CMAKE_INSTALL_DATADIR}/Mod/TechDraw
FILES_MATCHING
PATTERN "*.csv*"
)
INSTALL(
DIRECTORY
LineGroup

View File

@@ -0,0 +1,10 @@
CreatedByChkLst,ScaleChkLst,LabelChkLst,CommentChkLst,CompanyChkLst,LicenseChkLst,CreatedDateChkLst,LastModifiedDateChkLst
"author_name","fc-sc","drawing_title","freecad_drawing","nomsuperviseur","copyright","datedecreation","fc-date"
"nomauteur","echelle","document_type","titleline-1","companyname","rights","fecha2","date"
"authorname","масштаб","titre","sous_titre",compagnyname,,"date-1","dateverification"
"designed_by_name","escala","название","subtitulo",compagny,,"creationdate","дата"
"designed by name","scale","titulo", "subtitle",,,,"fecha3"
nom auteur,"fc-scale","drawing_name",,,,,"date-2"
,,"fc-title",,,,,"checkdate"
,,titleline-1,,,,,
,,freecad,,,,,
1 CreatedByChkLst ScaleChkLst LabelChkLst CommentChkLst CompanyChkLst LicenseChkLst CreatedDateChkLst LastModifiedDateChkLst
2 author_name fc-sc drawing_title freecad_drawing nomsuperviseur copyright datedecreation fc-date
3 nomauteur echelle document_type titleline-1 companyname rights fecha2 date
4 authorname масштаб titre sous_titre compagnyname date-1 dateverification
5 designed_by_name escala название subtitulo compagny creationdate дата
6 designed by name scale titulo subtitle fecha3
7 nom auteur fc-scale drawing_name date-2
8 fc-title checkdate
9 titleline-1
10 freecad

View File

@@ -30,6 +30,7 @@
<file>icons/actions/TechDraw_MoveView.svg</file>
<file>icons/actions/TechDraw_AxoLengthDimension.svg</file>
<file>icons/actions/TechDraw_AddOffsetVertex.svg</file>
<file>icons/actions/TechDraw_FillTemplateFields.svg</file>
<file>icons/actions/TechDraw_HoleShaftFit.svg</file>
<file>icons/actions/TechDraw_Multiview.svg</file>
<file>icons/actions/TechDraw_PageDefault.svg</file>

View File

@@ -0,0 +1,535 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="64"
height="64"
id="svg11300"
version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<title
id="title930">TechDraw_FillTemplateFields</title>
<defs
id="defs3">
<linearGradient
id="linearGradient3">
<stop
style="stop-color:#06739a;stop-opacity:1;"
offset="0"
id="stop1" />
<stop
id="stop2"
offset="0.43075874"
style="stop-color:#06739a;stop-opacity:0.49803922;" />
<stop
style="stop-color:#4e9a06;stop-opacity:0;"
offset="1"
id="stop3" />
</linearGradient>
<linearGradient
id="linearGradient4272">
<stop
style="stop-color:#8ae234;stop-opacity:1;"
offset="0"
id="stop4274" />
<stop
style="stop-color:#8ae234;stop-opacity:0;"
offset="1"
id="stop4276" />
</linearGradient>
<linearGradient
id="linearGradient4262">
<stop
style="stop-color:#4e9a06;stop-opacity:1;"
offset="0"
id="stop4264" />
<stop
id="stop4270"
offset="0.43075874"
style="stop-color:#4e9a06;stop-opacity:0.49803922;" />
<stop
style="stop-color:#4e9a06;stop-opacity:0;"
offset="1"
id="stop4266" />
</linearGradient>
<linearGradient
id="linearGradient3063">
<stop
id="stop3065"
offset="0"
style="stop-color:#729fcf;stop-opacity:1" />
<stop
id="stop3067"
offset="1"
style="stop-color:#204a87;stop-opacity:1" />
</linearGradient>
<linearGradient
id="linearGradient2690">
<stop
style="stop-color:#c4d7eb;stop-opacity:1;"
offset="0"
id="stop2692" />
<stop
style="stop-color:#c4d7eb;stop-opacity:0;"
offset="1"
id="stop2694" />
</linearGradient>
<linearGradient
id="linearGradient2682">
<stop
style="stop-color:#3977c3;stop-opacity:1;"
offset="0"
id="stop2684" />
<stop
style="stop-color:#89aedc;stop-opacity:0;"
offset="1"
id="stop2686" />
</linearGradient>
<linearGradient
id="linearGradient2402">
<stop
style="stop-color:#729fcf;stop-opacity:1;"
offset="0"
id="stop2404" />
<stop
style="stop-color:#528ac5;stop-opacity:1;"
offset="1"
id="stop2406" />
</linearGradient>
<linearGradient
id="linearGradient2380">
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="0"
id="stop2382" />
<stop
style="stop-color:#3465a4;stop-opacity:1"
offset="1"
id="stop2384" />
</linearGradient>
<linearGradient
id="linearGradient2871">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2873" />
<stop
style="stop-color:#3465a4;stop-opacity:1"
offset="1"
id="stop2875" />
</linearGradient>
<linearGradient
id="linearGradient2831">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2833" />
<stop
id="stop2855"
offset="0.33333334"
style="stop-color:#5b86be;stop-opacity:1;" />
<stop
style="stop-color:#83a8d8;stop-opacity:0;"
offset="1"
id="stop2835" />
</linearGradient>
<linearGradient
id="linearGradient2797">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop2799" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop2801" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient2797"
id="linearGradient1491"
gradientUnits="userSpaceOnUse"
x1="5.9649177"
y1="26.048164"
x2="52.854095"
y2="26.048164" />
<linearGradient
xlink:href="#linearGradient2797"
id="linearGradient1493"
gradientUnits="userSpaceOnUse"
x1="5.9649177"
y1="26.048164"
x2="52.854095"
y2="26.048164" />
<linearGradient
xlink:href="#linearGradient2871"
id="linearGradient1501"
gradientUnits="userSpaceOnUse"
x1="46.834816"
y1="45.264122"
x2="45.380436"
y2="50.939667" />
<linearGradient
xlink:href="#linearGradient3063"
id="linearGradient2386"
x1="42.703487"
y1="20.547306"
x2="26.605606"
y2="33.634254"
gradientUnits="userSpaceOnUse" />
<linearGradient
xlink:href="#linearGradient2402"
id="linearGradient2408"
x1="18.935766"
y1="23.667896"
x2="53.588623"
y2="26.649363"
gradientUnits="userSpaceOnUse" />
<linearGradient
xlink:href="#linearGradient2682"
id="linearGradient2688"
x1="36.713837"
y1="31.455952"
x2="37.124462"
y2="24.842253"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.370336,0,0,1.3589114,-0.33380651,-16.948724)" />
<linearGradient
xlink:href="#linearGradient2690"
id="linearGradient2696"
x1="32.647972"
y1="30.748846"
x2="37.124462"
y2="24.842253"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.370336,0,0,1.3589114,-0.33380651,-16.948724)" />
<linearGradient
xlink:href="#linearGradient2871"
id="linearGradient3036"
gradientUnits="userSpaceOnUse"
x1="46.834816"
y1="45.264122"
x2="45.380436"
y2="50.939667" />
<linearGradient
xlink:href="#linearGradient2402"
id="linearGradient3038"
gradientUnits="userSpaceOnUse"
x1="18.935766"
y1="23.667896"
x2="53.588623"
y2="26.649363" />
<linearGradient
xlink:href="#linearGradient2871"
id="linearGradient3040"
gradientUnits="userSpaceOnUse"
x1="46.834816"
y1="45.264122"
x2="45.380436"
y2="50.939667" />
<linearGradient
xlink:href="#linearGradient2831-7"
id="linearGradient1486-1"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.370336,0,0,1.3589114,0.30396568,-17.325948)"
x1="13.478554"
y1="10.612206"
x2="15.419417"
y2="19.115122" />
<linearGradient
id="linearGradient2831-7">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2833-4" />
<stop
id="stop2855-0"
offset="0.33333334"
style="stop-color:#5b86be;stop-opacity:1;" />
<stop
style="stop-color:#83a8d8;stop-opacity:0;"
offset="1"
id="stop2835-9" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient2847-8"
id="linearGradient1488-4"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-1.370336,0,0,-1.3589114,64.7954,45.353844)"
x1="37.128052"
y1="29.729605"
x2="37.065414"
y2="26.194071" />
<linearGradient
id="linearGradient2847-8">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2849-8" />
<stop
style="stop-color:#3465a4;stop-opacity:0;"
offset="1"
id="stop2851-2" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient2380-5"
id="linearGradient2386-4"
x1="62.513836"
y1="36.061237"
x2="15.984863"
y2="20.60858"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient2380-5">
<stop
style="stop-color:#b9cfe7;stop-opacity:1"
offset="0"
id="stop2382-5" />
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="1"
id="stop2384-1" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient2380-5"
id="linearGradient3034-7"
gradientUnits="userSpaceOnUse"
x1="62.513836"
y1="36.061237"
x2="15.984863"
y2="20.60858" />
<linearGradient
id="linearGradient3895">
<stop
style="stop-color:#b9cfe7;stop-opacity:1"
offset="0"
id="stop3897" />
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="1"
id="stop3899" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient2797-1"
id="linearGradient3861-1"
gradientUnits="userSpaceOnUse"
x1="5.9649177"
y1="26.048164"
x2="52.854095"
y2="26.048164" />
<linearGradient
id="linearGradient2797-1">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop2799-5" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop2801-2" />
</linearGradient>
<linearGradient
id="linearGradient2831-2">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2833-3" />
<stop
id="stop2855-1"
offset="0.33333334"
style="stop-color:#5b86be;stop-opacity:1;" />
<stop
style="stop-color:#83a8d8;stop-opacity:0;"
offset="1"
id="stop2835-6" />
</linearGradient>
<linearGradient
id="linearGradient3063-2">
<stop
id="stop3065-6"
offset="0"
style="stop-color:#729fcf;stop-opacity:1" />
<stop
id="stop3067-0"
offset="1"
style="stop-color:#204a87;stop-opacity:1" />
</linearGradient>
<linearGradient
id="linearGradient2380-9">
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="0"
id="stop2382-4" />
<stop
style="stop-color:#3465a4;stop-opacity:1"
offset="1"
id="stop2384-6" />
</linearGradient>
<linearGradient
xlink:href="#linearGradient4272"
id="linearGradient4306"
gradientUnits="userSpaceOnUse"
x1="60.093285"
y1="26.518738"
x2="60.368435"
y2="18.118267"
gradientTransform="matrix(-0.57654091,-0.61963683,0.61963683,-0.57654091,38.266148,42.812335)" />
<linearGradient
xlink:href="#linearGradient3"
id="linearGradient4308"
gradientUnits="userSpaceOnUse"
x1="43.341869"
y1="23.586662"
x2="49.500511"
y2="20.050343"
gradientTransform="matrix(-0.57654091,-0.61963683,0.61963683,-0.57654091,38.266148,42.812335)" />
<linearGradient
xlink:href="#linearGradient3775"
id="linearGradient3781"
x1="10"
y1="39.999996"
x2="53"
y2="25.999996"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.2484102,0,0,0.9960275,-55.906842,0.0478745)" />
<linearGradient
id="linearGradient3775">
<stop
style="stop-color:#d3d7cf;stop-opacity:1;"
offset="0"
id="stop3777" />
<stop
style="stop-color:#ffffff;stop-opacity:1"
offset="1"
id="stop3779" />
</linearGradient>
<linearGradient
gradientTransform="matrix(-0.57654091,-0.61963683,0.61963683,-0.57654091,90.477469,61.98592)"
y2="18.118267"
x2="60.368435"
y1="26.518738"
x1="60.093285"
gradientUnits="userSpaceOnUse"
id="linearGradient4306-2"
xlink:href="#linearGradient4272" />
<linearGradient
gradientTransform="matrix(-0.57654091,-0.61963683,0.61963683,-0.57654091,90.477469,61.98592)"
y2="20.050343"
x2="49.500511"
y1="23.586662"
x1="43.341869"
gradientUnits="userSpaceOnUse"
id="linearGradient4308-2"
xlink:href="#linearGradient4262" />
</defs>
<metadata
id="metadata4">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:creator>
<cc:Agent>
<dc:title>[bitacovir]</dc:title>
</cc:Agent>
</dc:creator>
<dc:source />
<cc:license
rdf:resource="http://creativecommons.org/publicdomain/zero/1.0/" />
<dc:title>TechDraw_FillTemplateFields</dc:title>
<dc:subject>
<rdf:Bag />
</dc:subject>
<dc:date>02-04-2021</dc:date>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:relation>https://www.freecad.org/wiki/index.php?title=Artwork</dc:relation>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/publicdomain/zero/1.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
</cc:License>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(0,16)"
style="display:inline">
<rect
transform="rotate(-90)"
y="3.0359571"
x="-44.671146"
height="57.7696"
width="57.426865"
id="rect2987"
style="fill:#eeeeec;fill-opacity:1;stroke:#555753;stroke-width:2.2302;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
ry="6.745532" />
<rect
ry="4.7776251"
style="display:inline;fill:#d3d7cf;fill-opacity:1;stroke:#ffffff;stroke-width:2.05866;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect2987-0"
width="53.009724"
height="53.326099"
x="-42.477673"
y="5.3086758"
transform="rotate(-90)" />
<path
id="path4666"
d="m 40.150485,33.988082 15.337556,0.04316 v 0"
style="fill:none;stroke:#555753;stroke-width:2.2302;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="path4666-7"
d="m 40.136433,38.981703 15.580329,0.04384 v 0"
style="fill:none;stroke:#555753;stroke-width:2.2302;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#555753;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 60.558491,28.981132 H 34.596226 v 15.335849"
id="path1172" />
<g
id="g1178"
style="fill:#2a58ff;fill-opacity:1">
<path
style="color:#000000;display:block;overflow:visible;visibility:visible;fill:#2a58ff;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4308);stroke-width:1.69275;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
d="m 37.856685,0.77245112 c 0,0 -6.534844,-8.07859422 -13.203526,2.48287458 l -6.073545,-6.5275374 c 0,0 10.394152,-8.8791283 19.277071,4.04466282 z"
id="path4298" />
<path
style="color:#000000;display:block;overflow:visible;visibility:visible;fill:#2a58ff;fill-opacity:1;fill-rule:nonzero;stroke:#172a04;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
d="M 18.42382,-2.8615117 C 30.177179,-19.612732 50.362307,-8.958074 52.399971,14.808121 l 8.185264,-0.05259 -14.501582,13.34136 -11.807768,-12.716404 c 0,0 8.648608,-0.157628 8.648608,-0.157628 C 41.193848,-1.2144478 29.122579,-13.096792 18.423823,-2.8615143 Z"
id="path4300" />
<g
style="fill:#2a58ff;fill-opacity:1;stroke:#34b5e2;stroke-width:0.732809;stroke-opacity:1"
transform="matrix(-0.03999158,-0.76842115,-0.76765118,0.03360048,61.561706,30.796332)"
id="g4302">
<path
style="color:#000000;display:block;overflow:visible;visibility:visible;fill:#2a58ff;fill-opacity:1;stroke:#34b5e2;stroke-width:2.20149;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:21;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
d="M 52.368857,42.344789 C 57.336994,33.465615 49.176003,12.601866 19.05552,12.672851 L 18.677956,5.6633463 7.4378077,19.282655 19.129354,29.167094 18.807724,20.554957 c 18.244937,0.381972 33.804002,9.457851 33.561133,21.789832 z"
id="path4304" />
</g>
</g>
<rect
style="fill:#10b100;fill-opacity:1;stroke:#77e234;stroke-width:4.149;stroke-opacity:1"
id="rect3"
width="1.7867694"
height="1.768358"
x="38.081394"
y="32.572205"
ry="0.884179" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -195,6 +195,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
pages->setCommand("Page");
*pages << "TechDraw_PageDefault";
*pages << "TechDraw_PageTemplate";
*pages << "TechDraw_FillTemplateFields";
*pages << "TechDraw_RedrawPage";
*pages << "TechDraw_PrintAll";
*pages << "Separator";
@@ -286,6 +287,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
pages->setCommand("TechDraw Pages");
*pages << "TechDraw_PageDefault";
*pages << "TechDraw_PageTemplate";
*pages << "TechDraw_FillTemplateFields";
*pages << "TechDraw_RedrawPage";
*pages << "TechDraw_PrintAll";
@@ -398,6 +400,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
pages->setCommand("TechDraw Pages");
*pages << "TechDraw_PageDefault";
*pages << "TechDraw_PageTemplate";
*pages << "TechDraw_FillTemplateFields";
*pages << "TechDraw_RedrawPage";
*pages << "TechDraw_PrintAll";

View File

@@ -0,0 +1,100 @@
# ***************************************************************************
# * Copyright (c) 2023 Syres *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
"""Provides the TechDraw FillTemplateFields GuiCommand."""
__title__ = "TechDrawTools.CommandFillTemplateFields"
__author__ = "Syres"
__url__ = "https://www.freecad.org"
__version__ = "00.02"
__date__ = "2023/12/07"
from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import FreeCADGui as Gui
import codecs
import csv
import os.path
import TechDrawTools
class CommandFillTemplateFields:
"""Use document info to populate the template fields."""
def GetResources(self):
"""Return a dictionary with data that will be used by the button or menu item."""
return {
"Pixmap": "actions/TechDraw_FillTemplateFields.svg",
"Accel": "",
"MenuText": QT_TRANSLATE_NOOP(
"TechDraw_FillTemplateFields", "Update template fields"
),
"ToolTip": QT_TRANSLATE_NOOP(
"TechDraw_FillTemplateFields",
"Use document info to populate the template fields",
),
}
def Activated(self):
"""Run the following code when the command is activated (button press)."""
TechDrawTools.TaskFillTemplateFields()
def IsActive(self):
"""Return True when the command should be active or False when it should be disabled (greyed)."""
if App.ActiveDocument:
objs = App.ActiveDocument.Objects
for obj in objs:
if obj.TypeId == "TechDraw::DrawPage":
file_path = (
App.getResourceDir()
+ "Mod/TechDraw/CSVdata/FillTemplateFields.csv"
)
if os.path.exists(file_path):
listofkeys = [
"CreatedByChkLst",
"ScaleChkLst",
"LabelChkLst",
"CommentChkLst",
"CompanyChkLst",
"LicenseChkLst",
"CreatedDateChkLst",
"LastModifiedDateChkLst",
]
with codecs.open(file_path, encoding="utf-8") as fp:
reader = csv.DictReader(fp)
page = obj
texts = page.Template.EditableTexts
if (
texts
and os.path.exists(file_path)
and listofkeys == reader.fieldnames
and obj.Views != []
):
return True
else:
return False
#
# The command must be "registered" with a unique name by calling its class.
Gui.addCommand("TechDraw_FillTemplateFields", CommandFillTemplateFields())

View File

@@ -0,0 +1,462 @@
# ***************************************************************************
# * Copyright (c) 2023 Syres *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
"""Provides the TechDraw FillTemplateFields Task Dialog."""
__title__ = "TechDrawTools.CommandFillTemplateFields"
__author__ = "Syres"
__url__ = "https://www.freecad.org"
__version__ = "00.02"
__date__ = "2023/12/07"
from PySide.QtCore import QT_TRANSLATE_NOOP
from PySide import QtCore, QtGui
from PySide.QtGui import QLineEdit, QCheckBox
import FreeCAD as App
import FreeCADGui as Gui
import datetime
from datetime import date
import csv
import codecs
import os.path
CreatedByChkLst = []
ScaleChkLst = []
LabelChkLst = []
CommentChkLst = []
CompanyChkLst = []
LicenseChkLst = []
CreatedDateChkLst = []
LastModifiedDateChkLst = []
listofkeys = [
"CreatedByChkLst",
"ScaleChkLst",
"LabelChkLst",
"CommentChkLst",
"CompanyChkLst",
"LicenseChkLst",
"CreatedDateChkLst",
"LastModifiedDateChkLst",
]
"""Run the following code when the command is activated (button press)."""
file_path = App.getResourceDir() + "Mod/TechDraw/CSVdata/FillTemplateFields.csv"
if os.path.exists(file_path):
with codecs.open(file_path, encoding="utf-8") as fp:
reader = csv.DictReader(fp)
if listofkeys == reader.fieldnames:
for row in reader:
CreatedByChkLst.append(row["CreatedByChkLst"])
ScaleChkLst.append(row["ScaleChkLst"])
LabelChkLst.append(row["LabelChkLst"])
CommentChkLst.append(row["CommentChkLst"])
CompanyChkLst.append(row["CompanyChkLst"])
LicenseChkLst.append(row["LicenseChkLst"])
CreatedDateChkLst.append(row["CreatedDateChkLst"])
LastModifiedDateChkLst.append(row["LastModifiedDateChkLst"])
else:
errorMsg = QtCore.QT_TRANSLATE_NOOP(
"Techdraw_FillTemplateFields",
" file does not contain the correct field names therefore exiting",
)
App.Console.PrintError(file_path + errorMsg + "\n")
else:
errorMsg = QtCore.QT_TRANSLATE_NOOP(
"Techdraw_FillTemplateFields",
" file has not been found therefore exiting",
)
App.Console.PrintError(file_path + errorMsg + "\n")
keyLst = []
class TaskFillTemplateFields:
def __init__(self):
objs = App.ActiveDocument.Objects
for obj in objs:
if (
obj.TypeId == "TechDraw::DrawPage"
and os.path.exists(file_path)
and listofkeys == reader.fieldnames
):
self.page = obj
if obj.Views == []:
msgBox = QtGui.QMessageBox()
msgTitle = QtCore.QT_TRANSLATE_NOOP(
"Techdraw_FillTemplateFields",
"View or Projection Group missing",
)
msg = QtCore.QT_TRANSLATE_NOOP(
"Techdraw_FillTemplateFields",
"There must be a view or projection group to establish data for the scale field in "
+ self.page.Label,
)
msgBox.setText(msg)
msgBox.setWindowTitle(msgTitle)
msgBox.exec_()
break
for pageObj in obj.Views:
if pageObj.isDerivedFrom("TechDraw::DrawViewPart"):
projgrp_view = self.page.Views[0]
elif pageObj.isDerivedFrom("TechDraw::DrawProjGroup"):
projgrp_view = self.page.Views[0]
self.texts = self.page.Template.EditableTexts
self.dialog = None
self.s1 = None
self.dialog = QtGui.QDialog()
self.dialog.resize(1050, 400)
self.dialog.setWindowTitle(
QtCore.QT_TRANSLATE_NOOP(
"TechDraw_FillTemplateFields", "Fill Template Fields in "
)
+ self.page.Label
)
self.dialog.move(400, 200)
self.la = QtGui.QGridLayout(self.dialog)
updateCb = QtCore.QT_TRANSLATE_NOOP(
"TechDraw_FillTemplateFields", "Update"
)
updateTxt = (
" ==>>"
)
self.checkBoxList = []
self.lineTextList = []
for key, value in self.texts.items():
App.Console.PrintLog("{0} = {1} | ".format(key, value))
if str(key).lower() in CreatedByChkLst:
t1 = QtGui.QLabel(value)
self.la.addWidget(t1, 0, 0)
self.cb1 = QtGui.QCheckBox(updateCb)
self.cb1.setObjectName(key)
self.cb1.setChecked(QtCore.Qt.Checked)
self.la.addWidget(self.cb1, 0, 1)
u1 = QtGui.QLabel(updateTxt)
self.la.addWidget(u1, 0, 2)
self.s1 = QtGui.QLineEdit()
self.s1.setText(App.ActiveDocument.CreatedBy)
self.la.addWidget(self.s1, 0, 3)
self.cb1.setObjectName(key)
keyLst.append(self.cb1.objectName())
self.checkBoxList.append(self.cb1)
self.lineTextList.append(self.s1)
self.cb1.clicked.connect(self.on_cb1_clicked)
if str(key).lower() in ScaleChkLst and projgrp_view:
t2 = QtGui.QLabel(value)
self.la.addWidget(t2, 1, 0)
self.cb2 = QtGui.QCheckBox(updateCb)
self.cb2.setObjectName(key)
self.cb2.setChecked(QtCore.Qt.Checked)
self.la.addWidget(self.cb2, 1, 1)
u2 = QtGui.QLabel(updateTxt)
self.la.addWidget(u2, 1, 2)
self.s2 = QtGui.QLineEdit()
self.la.addWidget(self.s2, 1, 3)
self.cb2.setObjectName(key)
keyLst.append(self.cb2.objectName())
self.checkBoxList.append(self.cb2)
self.lineTextList.append(self.s2)
self.cb2.clicked.connect(self.on_cb2_clicked)
if projgrp_view.Scale < 1:
self.s2.setText("1 : " + str(int(1 / projgrp_view.Scale)))
else:
self.s2.setText(str(int(projgrp_view.Scale)) + " : 1")
if str(key).lower() in LabelChkLst:
t3 = QtGui.QLabel(value)
self.la.addWidget(t3, 2, 0)
self.cb3 = QtGui.QCheckBox(updateCb)
self.cb3.setObjectName(key)
self.cb3.setChecked(QtCore.Qt.Checked)
self.la.addWidget(self.cb3, 2, 1)
u3 = QtGui.QLabel(updateTxt)
self.la.addWidget(u3, 2, 2)
self.s3 = QtGui.QLineEdit()
self.la.addWidget(self.s3, 2, 3)
self.s3.setText(App.ActiveDocument.Label)
self.cb3.setObjectName(key)
keyLst.append(self.cb3.objectName())
self.checkBoxList.append(self.cb3)
self.lineTextList.append(self.s3)
self.cb3.clicked.connect(self.on_cb3_clicked)
if str(key).lower() in CommentChkLst:
t4 = QtGui.QLabel(value)
self.la.addWidget(t4, 3, 0)
self.cb4 = QtGui.QCheckBox(updateCb)
self.cb4.setObjectName(key)
self.cb4.setChecked(QtCore.Qt.Checked)
self.la.addWidget(self.cb4, 3, 1)
u4 = QtGui.QLabel(updateTxt)
self.la.addWidget(u4, 3, 2)
self.s4 = QtGui.QLineEdit()
self.la.addWidget(self.s4, 3, 3)
self.s4.setText(App.ActiveDocument.Comment)
self.cb4.setObjectName(key)
keyLst.append(self.cb4.objectName())
self.checkBoxList.append(self.cb4)
self.lineTextList.append(self.s4)
self.cb4.clicked.connect(self.on_cb4_clicked)
if str(key).lower() in CompanyChkLst:
t5 = QtGui.QLabel(value)
self.la.addWidget(t5, 4, 0)
self.cb5 = QtGui.QCheckBox(updateCb)
self.cb5.setObjectName(key)
self.cb5.setChecked(QtCore.Qt.Checked)
self.la.addWidget(self.cb5, 4, 1)
u5 = QtGui.QLabel(updateTxt)
self.la.addWidget(u5, 4, 2)
self.s5 = QtGui.QLineEdit()
self.la.addWidget(self.s5, 4, 3)
self.s5.setText(App.ActiveDocument.Company)
self.cb5.setObjectName(key)
keyLst.append(self.cb5.objectName())
self.checkBoxList.append(self.cb5)
self.lineTextList.append(self.s5)
self.cb5.clicked.connect(self.on_cb5_clicked)
if str(key).lower() in LicenseChkLst:
t6 = QtGui.QLabel(value)
self.la.addWidget(t6, 5, 0)
self.cb6 = QtGui.QCheckBox(updateCb)
self.cb6.setObjectName(key)
self.cb6.setChecked(QtCore.Qt.Checked)
self.la.addWidget(self.cb6, 5, 1)
u6 = QtGui.QLabel(updateTxt)
self.la.addWidget(u6, 5, 2)
self.s6 = QtGui.QLineEdit()
self.la.addWidget(self.s6, 5, 3)
self.s6.setText(App.ActiveDocument.License)
self.cb6.setObjectName(key)
keyLst.append(self.cb6.objectName())
self.checkBoxList.append(self.cb6)
self.lineTextList.append(self.s6)
self.cb6.clicked.connect(self.on_cb6_clicked)
if str(key).lower() in LastModifiedDateChkLst:
t7 = QtGui.QLabel(value)
self.la.addWidget(t7, 6, 0)
self.cb7 = QtGui.QCheckBox(updateCb)
self.cb7.setObjectName(key)
self.cb7.setChecked(QtCore.Qt.Checked)
self.la.addWidget(self.cb7, 6, 1)
u7 = QtGui.QLabel(updateTxt)
self.la.addWidget(u7, 6, 2)
self.s7 = QtGui.QLineEdit()
self.la.addWidget(self.s7, 6, 3)
self.cb7.setObjectName(key)
keyLst.append(self.cb7.objectName())
self.checkBoxList.append(self.cb7)
self.lineTextList.append(self.s7)
self.cb7.clicked.connect(self.on_cb7_clicked)
try:
dt = datetime.datetime.strptime(
App.ActiveDocument.LastModifiedDate,
"%Y-%m-%dT%H:%M:%SZ",
)
if value == "MM/DD/YYYY":
self.s7.setText(
"{0}/{1}/{2}".format(dt.month, dt.day, dt.year)
)
elif value == "YYYY-MM-DD":
self.s7.setText(
"{0}-{1}-{2}".format(dt.year, dt.month, dt.day)
)
else:
self.s7.setText(
"{0}/{1}/{2}".format(dt.day, dt.month, dt.year)
)
except ValueError:
App.Console.PrintLog(
"DateTime format not recognised: "
+ App.ActiveDocument.LastModifiedDate
+ "\n"
)
self.s7.setText(
"{0}/{1}/{2}".format(date.today().day, date.today().month, date.today().year)
)
if str(key).lower() in CreatedDateChkLst:
t8 = QtGui.QLabel(value)
self.la.addWidget(t8, 7, 0)
self.cb8 = QtGui.QCheckBox(updateCb)
self.cb8.setObjectName(key)
self.cb8.setChecked(QtCore.Qt.Checked)
self.la.addWidget(self.cb8, 7, 1)
u8 = QtGui.QLabel(updateTxt)
self.la.addWidget(u8, 7, 2)
self.s8 = QtGui.QLineEdit()
self.la.addWidget(self.s8, 7, 3)
self.cb8.setObjectName(key)
keyLst.append(self.cb8.objectName())
self.checkBoxList.append(self.cb8)
self.lineTextList.append(self.s8)
self.cb8.clicked.connect(self.on_cb8_clicked)
try:
dt = datetime.datetime.strptime(
App.ActiveDocument.CreationDate, "%Y-%m-%dT%H:%M:%SZ"
)
if value == "MM/DD/YYYY":
self.s8.setText(
"{0}/{1}/{2}".format(dt.month, dt.day, dt.year)
)
elif value == "YYYY-MM-DD":
self.s8.setText(
"{0}-{1}-{2}".format(dt.year, dt.month, dt.day)
)
else:
self.s8.setText(
"{0}/{1}/{2}".format(dt.day, dt.month, dt.year)
)
except ValueError:
App.Console.PrintLog(
"DateTime format not recognised: "
+ App.ActiveDocument.LastModifiedDate
+ "\n"
)
self.s8.setText(
"{0}/{1}/{2}".format(date.today().day, date.today().month, date.today().year)
)
if len(keyLst) > 1:
self.cbAll = QtGui.QCheckBox(
QtCore.QT_TRANSLATE_NOOP(
"TechDraw_FillTemplateFields",
"Update All",
)
)
self.cbAll.setChecked(QtCore.Qt.Checked)
self.la.addWidget(self.cbAll, 8, 1)
self.cbAll.clicked.connect(self.on_cbAll_clicked)
if len(keyLst) > 0:
self.okbox = QtGui.QDialogButtonBox(self.dialog)
self.okbox.setOrientation(QtCore.Qt.Horizontal)
self.okbox.setStandardButtons(
QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok
)
self.la.addWidget(self.okbox)
QtCore.QObject.connect(
self.okbox, QtCore.SIGNAL("accepted()"), self.proceed
)
QtCore.QObject.connect(
self.okbox, QtCore.SIGNAL("rejected()"), self.close
)
self.button = self.okbox.button(QtGui.QDialogButtonBox.Ok)
self.button.setEnabled(True)
QtCore.QMetaObject.connectSlotsByName(self.dialog)
self.dialog.show()
self.dialog.exec_()
else:
msgBox = QtGui.QMessageBox()
msgTitle = QtCore.QT_TRANSLATE_NOOP(
"Techdraw_FillTemplateFields",
"Corresponding template fields missing",
)
msg = QtCore.QT_TRANSLATE_NOOP(
"Techdraw_FillTemplateFields",
"There were no corresponding fields found in "
+ self.page.Label,
)
msgBox.setText(msg)
msgBox.setWindowTitle(msgTitle)
msgBox.exec_()
def on_cbAll_clicked(self):
if self.cbAll.isChecked():
for cbEach in self.checkBoxList:
cbEach.setChecked(QtCore.Qt.Checked)
self.button.setEnabled(True)
else:
for cbEach in self.checkBoxList:
cbEach.setChecked(QtCore.Qt.Unchecked)
self.button.setEnabled(False)
def on_cb1_clicked(self):
if self.cb1.isChecked():
self.button.setEnabled(True)
else:
self.chkEachChkBox()
def on_cb2_clicked(self):
if self.cb2.isChecked():
self.button.setEnabled(True)
else:
self.chkEachChkBox()
def on_cb3_clicked(self):
if self.cb3.isChecked():
self.button.setEnabled(True)
else:
self.chkEachChkBox()
def on_cb4_clicked(self):
if self.cb4.isChecked():
self.button.setEnabled(True)
else:
self.chkEachChkBox()
def on_cb5_clicked(self):
if self.cb5.isChecked():
self.button.setEnabled(True)
else:
self.chkEachChkBox()
def on_cb6_clicked(self):
if self.cb6.isChecked():
self.button.setEnabled(True)
else:
self.chkEachChkBox()
def on_cb7_clicked(self):
if self.cb7.isChecked():
self.button.setEnabled(True)
else:
self.chkEachChkBox()
def on_cb8_clicked(self):
if self.cb8.isChecked():
self.button.setEnabled(True)
else:
self.chkEachChkBox()
def chkEachChkBox(self):
boolFnd = False
for cbEach in self.checkBoxList:
if cbEach.isChecked():
boolFnd = True
if boolFnd:
self.button.setEnabled(True)
else:
self.button.setEnabled(False)
def proceed(self):
i = 0
for cb in self.checkBoxList:
if cb.isChecked():
self.texts[keyLst[i]] = self.lineTextList[i].text()
i += 1
self.page.Template.EditableTexts = self.texts
self.close()
def close(self):
self.dialog.hide()
return True

View File

@@ -36,7 +36,9 @@ from .CommandMoveView import CommandMoveView
from .CommandAxoLengthDimension import CommandAxoLengthDimension
from .CommandVertexCreations import CommandVertexCreationGroup
from .CommandHoleShaftFit import CommandHoleShaftFit
from .CommandFillTemplateFields import CommandFillTemplateFields
from .TaskShareView import TaskShareView
from .TaskMoveView import TaskMoveView
from .TaskHoleShaftFit import TaskHoleShaftFit
from .TaskAddOffsetVertex import TaskAddOffsetVertex
from .TaskFillTemplateFields import TaskFillTemplateFields