Skip to content

Commit

Permalink
dimensions_svg.py to understand imperialistic dimentions :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
nortikin committed Jan 20, 2022
1 parent 280b94b commit 73f7778
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
28 changes: 26 additions & 2 deletions nodes/svg/dimensions_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,21 @@ def draw_dimension_text(self, dim_loc_a, dim_loc_b, angle, document):
text_svg += self.text_attributes.draw(document)
text_svg += '>'
precision = self.node.decimal_precision
p_format = "{:10."+str(precision)+"f}"
text_svg += p_format.format((dim_loc_b - dim_loc_a).length)
if self.node.units_real == 'Metric':
p_format = "{:10."+str(precision)+"f}"
text_svg += p_format.format((dim_loc_b - dim_loc_a).length)
else:
feets = (dim_loc_b - dim_loc_a).length//0.3048
if feets < 2:
inches = ((dim_loc_b - dim_loc_a).length/0.0254)
else:
p_format = "{:10.0f}"
inches = (((dim_loc_b - dim_loc_a).length%0.3048)/0.0254)
text_svg += p_format.format(feets)
text_svg += "ft"
p_format = "{:10."+str(precision)+"f}"
text_svg += p_format.format(inches)
text_svg += "in"
text_svg += f' {self.node.units}'
text_svg += '</text>'

Expand Down Expand Up @@ -201,6 +214,14 @@ class SvSvgDimensionNode(bpy.types.Node, SverchCustomTreeNode):
description='units',
default='',
update=updateNode)

units_real: EnumProperty(
name='Units_real',
description='Dimentions feets or meters',
items=enum_item_4(['Metric', 'Imperialistic']),
default='Metric',
update=updateNode)

text: StringProperty(
name='Text',
description='Text',
Expand Down Expand Up @@ -231,6 +252,7 @@ def draw_buttons(self, context, layout):
layout.prop(self, "line_extension", expand=False)
layout.prop(self, "decimal_precision", expand=False)
layout.prop(self, "units", expand=False)
layout.prop(self, "units_real", expand=True)
layout.prop(self, "font_family", expand=False)
if self.font_family == 'user':
layout.prop(self, "user_font")
Expand Down Expand Up @@ -263,3 +285,5 @@ def register():

def unregister():
bpy.utils.unregister_class(SvSvgDimensionNode)

if __name__ == '__main__': register()
4 changes: 2 additions & 2 deletions utils/sv_svg_custom_server.htm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

</div>
<div id="div2">
<span id="file_name">File: "/home/ololo/Documents/BLENDER/SVERCHOK/Blends2.90/svg/Пазлы_Матвей_01.blend.svg"</span>
<span id="file_name">File: "/home/ololo/Documents/BLENDER/SVERCHOK/Blends2.90/svg/dimentions_inch.svg"</span>

This comment has been minimized.

Copy link
@nortikin

nortikin Jan 21, 2022

Author Owner

git rm --cached

<button id="PauseButton" onclick="pause_feed()">Pause</button>
<button id="PlayButton"onclick="live_feed = start_feed()">Play</button>
<form id="refresh_slider">
Expand All @@ -71,7 +71,7 @@
<script>
var a=0
var paused= false
var file_name = "/home/ololo/Documents/BLENDER/SVERCHOK/Blends2.90/svg/Пазлы_Матвей_01.blend.svg"
var file_name = "/home/ololo/Documents/BLENDER/SVERCHOK/Blends2.90/svg/dimentions_inch.svg"
function reload_svg(){
<!-- console.log(a) -->

Expand Down

0 comments on commit 73f7778

Please sign in to comment.