fix casting type error #46

This commit is contained in:
Mario Voigt 2022-12-06 21:38:18 +01:00
parent 1a73175e0d
commit bdff438ee0
2 changed files with 64 additions and 53 deletions

View File

@ -4,32 +4,41 @@
<id>fablabchemnitz.de.box_maker_mehr_boxes</id>
<param name="page" type="notebook">
<page name="page_1" gui-text="Sizes">
<param name="unit" gui-text="Unit" type="optiongroup" appearance="combo">
<option value="mm">mm</option>
<option value="cm">cm</option>
<option value="in">in</option>
</param>
<label appearance="header">Size Options</label>
<param name="inside" type="optiongroup" appearance="combo" gui-text="Box Dimensions">
<option value="1">Inside</option>
<option value="0">Outside</option>
</param>
<param name="X_size" type="float" precision="2" min="0.0" max="1000000.0" gui-text="X axis lenght">100.0</param>
<param name="Y_size" type="float" precision="2" min="0.0" max="1000000.0" gui-text="Y axis lenght">100.0</param>
<param name="Z_size" type="float" precision="2" min="0.0" max="1000000.0" gui-text="Z axis lenght">100.0</param>
<label appearance="header">Tab Options</label>
<param name="tab_mode" gui-text="Tab Mode" type="optiongroup" appearance="combo">
<option value="number">amount</option>
<option value="size">size</option>
</param>
<param name="tab_size" type="float" precision="2" min="0.0" max="10000.0" gui-text="target tab size">4.0</param>
<param name="X_tabs" type="int" min="0" max="100000" gui-text="Tabs in X axis">3</param>
<param name="Y_tabs" type="int" min="0" max="100000" gui-text="Tabs in Y axis">3</param>
<param name="Z_tabs" type="int" min="0" max="100000" gui-text="Tabs in Z axis">3</param>
<label appearance="header">Material Options</label>
<param name="thickness" type="float" precision="2" min="0.0" max="10000.0" gui-text="Material Thickness">4.0</param>
<param name="kerf" type="float" precision="3" min="0.0" max="10000.0" gui-text="Beam diameter">0.2</param>
<param name="spaceing" type="float" precision="2" min="0.0" max="10000.0" gui-text="Space Between Parts">1.0</param>
<hbox>
<vbox>
<param name="unit" gui-text="Unit" type="optiongroup" appearance="combo">
<option value="mm">mm</option>
<option value="cm">cm</option>
<option value="in">in</option>
</param>
<label appearance="header">Size Options</label>
<param name="inside" type="optiongroup" appearance="combo" gui-text="Box Dimensions">
<option value="1">Inside</option>
<option value="0">Outside</option>
</param>
<label appearance="header">Material Options</label>
<param name="thickness" type="float" precision="2" min="0.0" max="10000.0" gui-text="Material Thickness">4.0</param>
<param name="kerf" type="float" precision="3" min="0.0" max="10000.0" gui-text="Beam diameter">0.2</param>
<param name="spacing" type="float" precision="2" min="0.0" max="10000.0" gui-text="Space Between Parts">1.0</param>
</vbox>
<spacer/>
<vbox>
<param name="X_size" type="float" precision="2" min="0.0" max="1000000.0" gui-text="X axis lenght">100.0</param>
<param name="Y_size" type="float" precision="2" min="0.0" max="1000000.0" gui-text="Y axis lenght">100.0</param>
<param name="Z_size" type="float" precision="2" min="0.0" max="1000000.0" gui-text="Z axis lenght">100.0</param>
<label appearance="header">Tab Options</label>
<param name="tab_mode" gui-text="Tab Mode" type="optiongroup" appearance="combo">
<option value="number">amount</option>
<option value="size">size</option>
</param>
<label>... for Tab Mode "size"</label>
<param name="tab_size" type="float" precision="2" min="0.0" max="10000.0" gui-text="target tab size">4.0</param>
<label>... for Tab Mode "amount"</label>
<param name="X_tabs" type="int" min="0" max="100000" gui-text="Tabs in X axis">3</param>
<param name="Y_tabs" type="int" min="0" max="100000" gui-text="Tabs in Y axis">3</param>
<param name="Z_tabs" type="int" min="0" max="100000" gui-text="Tabs in Z axis">3</param>
</vbox>
</hbox>
</page>
<page name="page_2" gui-text="Draw sides">
<param name="d_top" type="bool" gui-text="Draw top side (XxY)">true</param>

View File

@ -29,14 +29,14 @@ class mehr_box_maker(inkex.EffectExtension):
pars.add_argument('--page',default='page_1')
pars.add_argument('--unit',default='mm')
pars.add_argument('--inside')
pars.add_argument('--X_size',type=float,default='0.0')
pars.add_argument('--Y_size',type=float,default='0.0')
pars.add_argument('--Z_size',type=float,default='0.0')
pars.add_argument('--X_size',type=float,default=0.0)
pars.add_argument('--Y_size',type=float,default=0.0)
pars.add_argument('--Z_size',type=float,default=0.0)
pars.add_argument('--tab_mode',default='number')
pars.add_argument('--tab_size',type=float,default='0.0')
pars.add_argument('--X_tabs',type=int,default='0')
pars.add_argument('--Y_tabs',type=int,default='0')
pars.add_argument('--Z_tabs',type=int,default='0')
pars.add_argument('--tab_size',type=float,default=0.0)
pars.add_argument('--X_tabs',type=int,default=0)
pars.add_argument('--Y_tabs',type=int,default=0)
pars.add_argument('--Z_tabs',type=int,default=0)
pars.add_argument('--d_top',type=inkex.Boolean,default=True)
pars.add_argument('--d_bottom',type=inkex.Boolean,default=True)
pars.add_argument('--d_left',type=inkex.Boolean,default=True)
@ -45,7 +45,7 @@ class mehr_box_maker(inkex.EffectExtension):
pars.add_argument('--d_back',type=inkex.Boolean,default=True)
pars.add_argument('--thickness',type=float,default=4,help='Thickness of Material')
pars.add_argument('--kerf',type=float,default=0.2)
pars.add_argument('--spaceing',type=float,default=1)
pars.add_argument('--spacing',type=float,default=1)
pars.add_argument('--X_compartments',type=int,default=1)
pars.add_argument('--X_divisions')
pars.add_argument('--X_mode')
@ -59,7 +59,7 @@ class mehr_box_maker(inkex.EffectExtension):
thickness=self.svg.unittouu(str(self.options.thickness)+self.options.unit)
kerf=self.svg.unittouu(str(self.options.kerf)+self.options.unit)/2#kerf is diameter in UI and radius in lib
spaceing=self.svg.unittouu(str(self.options.spaceing)+self.options.unit)
spacing=self.svg.unittouu(str(self.options.spacing)+self.options.unit)
XYZ=[self.svg.unittouu(str(self.options.X_size)+self.options.unit),self.svg.unittouu(str(self.options.Y_size)+self.options.unit),self.svg.unittouu(str(self.options.Z_size)+self.options.unit)]
if(self.options.inside=='0'):#if the sizes are outside sizes reduce the size by thickness if the side gets drawn
@ -114,7 +114,9 @@ class mehr_box_maker(inkex.EffectExtension):
Tabs_XYZ=[self.options.X_tabs,self.options.Y_tabs,self.options.Z_tabs]
else:#compute apropriate number of tabs for the edges
tab_size=float(self.svg.unittouu(str(self.options.tab_size)+self.options.unit))
Tabs_XYZ=[max(1,int(XYZ[0]/(tab_size))/2),max(1,int(XYZ[1]/(tab_size))/2),max(1,int(XYZ[2]/(tab_size))/2)]
Tabs_XYZ=[int(max(1,int(XYZ[0]/(tab_size))/2)),
int(max(1,int(XYZ[1]/(tab_size))/2)),
int(max(1,int(XYZ[2]/(tab_size))/2))]
#top and bottom plate
tabs_tb=(Tabs_XYZ[0] if self.options.d_back else 0,Tabs_XYZ[1] if self.options.d_right else 0,Tabs_XYZ[0] if self.options.d_front else 0,Tabs_XYZ[1] if self.options.d_left else 0)
@ -149,40 +151,40 @@ class mehr_box_maker(inkex.EffectExtension):
X_offset=0
Y_offset=0
if(self.options.d_top):
Plate_tb.draw([X_offset+spaceing,spaceing],["#000000","#ff0000"],self.svg.get_current_layer())#drawing a plate using black for the outline and red for holes
X_offset+=Plate_tb.AABB[0]+spaceing
Plate_tb.draw([X_offset+spacing,spacing],["#000000","#ff0000"],self.svg.get_current_layer())#drawing a plate using black for the outline and red for holes
X_offset+=Plate_tb.AABB[0]+spacing
Y_offset=max(Y_offset,Plate_tb.AABB[1])
if(self.options.d_bottom):
Plate_tb.draw([X_offset+spaceing,spaceing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_tb.AABB[0]+spaceing
Plate_tb.draw([X_offset+spacing,spacing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_tb.AABB[0]+spacing
Y_offset=max(Y_offset,Plate_tb.AABB[1])
if(self.options.d_left):
Plate_lr.draw([X_offset+spaceing,spaceing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_lr.AABB[0]+spaceing
Plate_lr.draw([X_offset+spacing,spacing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_lr.AABB[0]+spacing
Y_offset=max(Y_offset,Plate_lr.AABB[1])
if(self.options.d_right):
Plate_lr.draw([X_offset+spaceing,spaceing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_lr.AABB[0]+spaceing
Plate_lr.draw([X_offset+spacing,spacing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_lr.AABB[0]+spacing
Y_offset=max(Y_offset,Plate_lr.AABB[1])
if(self.options.d_front):
Plate_fb.draw([X_offset+spaceing,spaceing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_fb.AABB[0]+spaceing
Plate_fb.draw([X_offset+spacing,spacing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_fb.AABB[0]+spacing
Y_offset=max(Y_offset,Plate_fb.AABB[1])
if(self.options.d_back):
Plate_fb.draw([X_offset+spaceing,spaceing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_fb.AABB[0]+spaceing
Plate_fb.draw([X_offset+spacing,spacing],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_fb.AABB[0]+spacing
Y_offset=max(Y_offset,Plate_fb.AABB[1])
X_offset=0
for i in range(self.options.X_compartments-1):
Plate_xc.draw([X_offset+spaceing,spaceing+Y_offset],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_xc.AABB[0]+spaceing
Plate_xc.draw([X_offset+spacing,spacing+Y_offset],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_xc.AABB[0]+spacing
X_offset=0
Y_offset+=spaceing+Plate_xc.AABB[1]
Y_offset+=spacing+Plate_xc.AABB[1]
for i in range(self.options.Y_compartments-1):
Plate_yc.draw([X_offset+spaceing,spaceing+Y_offset],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_yc.AABB[0]+spaceing
Plate_yc.draw([X_offset+spacing,spacing+Y_offset],["#000000","#ff0000"],self.svg.get_current_layer())
X_offset+=Plate_yc.AABB[0]+spacing
if __name__ == '__main__':
mehr_box_maker().run()