User Tools

Site Tools


freecad

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
freecad [2021/03/23 13:23] ssm2017freecad [2024/02/14 00:39] (current) ssm2017
Line 1: Line 1:
 ====== freecad ====== ====== freecad ======
 +===== blender 3 to freecad 19 =====
 + blender :
 +  obj
 +   include :
 +    selection only
 +    onjects as onj objects
 +   transform :
 +    scale 1000
 +    forward y forward
 +    up z up
 +    geometry :
 +    triangulate faces
 +
 + freecad :
 +  file / import
 +   alias mesh = 1 object
 +   wavefront obj = multiple objects
 +  select all
 +  part workbench :
 +   menu part / create shape from mesh
 +   tolerance : 0.10
 +   delete selection
 +   select all
 +   menu part / create a copy / refine shape
 +   select copied
 +   menu part / convert to solid
 +   delete others
 ====== Techdraw ====== ====== Techdraw ======
 Update cartridge Update cartridge
Line 48: Line 75:
 updateValues(getAuthor(), getTime()) updateValues(getAuthor(), getTime())
 </sxh> </sxh>
 +
 +====== Lighting test ======
 +===== Set Properties =====
 +<sxh python>
 +def setLightingProperties():
 + selection = FreeCADGui.Selection.getSelection()
 + # stop if none selected
 + if len(selection) < 1:
 + App.Console.PrintMessage("Please select devices")
 + return
 + # assign properties
 + for item in selection:
 + # delete all the "lighting" properties
 + for prop in item.PropertiesList:
 + if item.getGroupOfProperty(prop) == "Lighting":
 + item.removeProperty(prop)
 + App.Console.PrintMessage("Property "+ prop+ " deleted from "+ item.Label+ "\n")
 + # fixture type
 + if not hasattr(item,"Lighting_FixtureType"):
 + item.addProperty("App::PropertyString", "FixtureType", "Lighting")
 + # channel
 + if not hasattr(item,"Lighting_Channel"):
 + item.addProperty("App::PropertyInteger", "Channel", "Lighting")
 + # dimmer
 + if not hasattr(item,"Lighting_Dimmer"):
 + item.addProperty("App::PropertyInteger", "Dimmer", "Lighting")
 + # gel
 + if not hasattr(item,"Lighting_Gel"):
 + item.addProperty("App::PropertyString", "Gel", "Lighting")
 +
 +setLightingProperties()
 +</sxh>
 +===== Build sheets =====
 +<sxh python>
 +import collections
 +# get doc
 +doc = FreeCAD.ActiveDocument
 +
 +# ====================
 +# create spreadsheets
 +# ====================
 +
 +def deleteSheets():
 + sheets = {"fixturesCount":"Fixtures Count",
 + "gelsCount": "Gels Count",
 + "fixturesListByChannel": "Fixtures List By Channel",
 + "fixturesListByDimmer": "Fixtures List By Dimmer"}
 + # delete old spreadsheets
 + for sheet_name, sheet_label in sheets.items():
 + if doc.getObject(sheet_name):
 + doc.removeObject(sheet_name)
 + App.Console.PrintMessage("Old "+ sheet_name+ " sheeet deleted\n")
 + doc.recompute()
 +
 +# fixtures list
 +fixtures_count_sheet = doc.getObject('fixturesCountSheet')
 +if not fixtures_count_sheet:
 + fixtures_count_sheet = doc.addObject('Spreadsheet::Sheet','fixturesCountSheet')
 + fixtures_count_sheet.Label = "Fixtures Count"
 + App.Console.PrintMessage("New 'Fixtures Count' sheet created\n")
 +# empty the sheet
 +fixtures_count_sheet.clearAll()
 +# build first line
 +fixtures_count_sheet.set("A1", "Type")
 +fixtures_count_sheet.set("B1", "Qty")
 +fixtures_count_sheet.setStyle('A1:B1', 'bold', 'add')
 +#doc.recompute()
 +
 +# gels list
 +gels_count_sheet = doc.getObject('gelsCountSheet')
 +if not gels_count_sheet:
 + gels_count_sheet = doc.addObject('Spreadsheet::Sheet','gelsCountSheet')
 + gels_count_sheet.Label = "Gels Count"
 + App.Console.PrintMessage("New 'Gels Count' sheet created\n")
 +# empty the sheet
 +gels_count_sheet.clearAll()
 +# build first line
 +gels_count_sheet.set("A1", "Type")
 +gels_count_sheet.set("B1", "Qty")
 +gels_count_sheet.setStyle('A1:B1', 'bold', 'add')
 +#doc.recompute()
 +
 +# fixtures list by channel
 +fixtures_list_by_channel_sheet = doc.getObject('fixturesListByChannelSheet')
 +if not fixtures_list_by_channel_sheet:
 + fixtures_list_by_channel_sheet = doc.addObject('Spreadsheet::Sheet','fixturesListByChannelSheet')
 + fixtures_list_by_channel_sheet.Label = "Fixtures List By Channel"
 + App.Console.PrintMessage("New 'Fixtures List By Channel' sheet created\n")
 +# empty the sheet
 +fixtures_list_by_channel_sheet.clearAll()
 +# build first line
 +fixtures_list_by_channel_sheet.set("A1", "Channel")
 +fixtures_list_by_channel_sheet.set("B1", "Dimmer")
 +fixtures_list_by_channel_sheet.set("C1", "Type")
 +fixtures_list_by_channel_sheet.set("D1", "Gel")
 +fixtures_list_by_channel_sheet.set("E1", "Label")
 +fixtures_list_by_channel_sheet.setStyle('A1:E1', 'bold', 'add')
 +#doc.recompute()
 +
 +# fixtures list by dimmer
 +fixtures_list_by_dimmer_sheet = doc.getObject('fixturesListByDimmerSheet')
 +if not fixtures_list_by_dimmer_sheet:
 + fixtures_list_by_dimmer_sheet = doc.addObject('Spreadsheet::Sheet','fixturesListByDimmerSheet')
 + fixtures_list_by_dimmer_sheet.Label = "Fixtures List By Dimmer"
 + App.Console.PrintMessage("New 'Fixtures List By Dimmer' sheet created\n")
 +# empty the sheet
 +fixtures_list_by_dimmer_sheet.clearAll()
 +# build first line
 +fixtures_list_by_dimmer_sheet.set("A1", "Dimmer")
 +fixtures_list_by_dimmer_sheet.set("B1", "Channel")
 +fixtures_list_by_dimmer_sheet.set("C1", "Type")
 +fixtures_list_by_dimmer_sheet.set("D1", "Gel")
 +fixtures_list_by_dimmer_sheet.set("E1", "Label")
 +fixtures_list_by_dimmer_sheet.setStyle('A1:E1', 'bold', 'add')
 +doc.recompute()
 +
 +# ====================
 +# parse objects
 +# ====================
 +objs = FreeCAD.ActiveDocument.Objects
 +#App.Console.PrintMessage(str(objs) + "\n")
 +
 +# fill the devices list
 +fixtures_types_count = {}
 +gels_types_count = {}
 +fixtures_list_by_channel = {}
 +fixtures_list_by_dimmer = {}
 +for obj in objs:
 + if obj.isDerivedFrom("Part::Part2DObject"):
 + if hasattr(obj,"FixtureType"):
 + # get properties
 + fixture_type = obj.getPropertyByName("FixtureType")
 + fixture_gel = obj.getPropertyByName("Gel")
 + fixture_channel = obj.getPropertyByName("Channel")
 + fixture_dimmer = obj.getPropertyByName("Dimmer")
 + # fill the devices count
 + if fixture_type not in fixtures_types_count:
 + fixtures_types_count[fixture_type] = 0
 + fixtures_types_count[fixture_type] += 1
 + # fill the gels count
 + if fixture_gel not in gels_types_count:
 + gels_types_count[fixture_gel] = 0
 + gels_types_count[fixture_gel] += 1
 + # fill the list by channel
 + if not fixture_channel in fixtures_list_by_channel:
 + fixtures_list_by_channel[fixture_channel] = []
 + fixtures_list_by_channel[fixture_channel].append(obj)
 + # fill the list by dimmer
 + if not fixture_dimmer in fixtures_list_by_dimmer:
 + fixtures_list_by_dimmer[fixture_dimmer] = []
 + fixtures_list_by_dimmer[fixture_dimmer].append(obj)
 +
 +#App.Console.PrintMessage(str(fixtures_types_count)+"\n")
 +#App.Console.PrintMessage(str(gels_types_count)+"\n")
 +#App.Console.PrintMessage(str(fixtures_list_by_channel)+"\n")
 +#App.Console.PrintMessage(str(fixtures_list_by_dimmer)+"\n")
 +
 +# order by key
 +fixtures_types_count = collections.OrderedDict(sorted(fixtures_types_count.items()))
 +gels_types_count = collections.OrderedDict(sorted(gels_types_count.items()))
 +fixtures_list_by_channel = collections.OrderedDict(sorted(fixtures_list_by_channel.items()))
 +fixtures_list_by_dimmer = collections.OrderedDict(sorted(fixtures_list_by_dimmer.items()))
 +
 +# ==============================
 +# fill the fixtures count sheet
 +# ==============================
 +cell_idx = 2
 +for fixt, qty in fixtures_types_count.items():
 + type_cell = "A"+ str(cell_idx)
 + qty_cell = "B"+ str(cell_idx)
 + fixtures_count_sheet.set(type_cell, fixt)
 + fixtures_count_sheet.set(qty_cell, str(qty))
 + cell_idx += 1
 +# ==============================
 +# fill the gels count sheet
 +# ==============================
 +cell_idx = 2
 +for gel, qty in gels_types_count.items():
 + type_cell = "A"+ str(cell_idx)
 + qty_cell = "B"+ str(cell_idx)
 + gels_count_sheet.set(type_cell, gel)
 + gels_count_sheet.set(qty_cell, str(qty))
 + cell_idx += 1
 +# ==================================
 +# fill the fixtures list by channel
 +# ==================================
 +cell_idx = 2
 +for k,v in fixtures_list_by_channel.items():
 + for fixture in fixtures_list_by_channel[k]:
 + channel_cell = "A"+ str(cell_idx)
 + dimmer_cell = "B"+ str(cell_idx)
 + type_cell = "C"+ str(cell_idx)
 + gel_cell = "D"+ str(cell_idx)
 + label_cell = "E"+ str(cell_idx)
 + fixtures_list_by_channel_sheet.set(channel_cell, str(fixture.getPropertyByName("Channel")))
 + fixtures_list_by_channel_sheet.set(dimmer_cell, str(fixture.getPropertyByName("Dimmer")))
 + fixtures_list_by_channel_sheet.set(type_cell, fixture.getPropertyByName("Gel"))
 + fixtures_list_by_channel_sheet.set(gel_cell, fixture.getPropertyByName("FixtureType"))
 + fixtures_list_by_channel_sheet.set(label_cell, fixture.Label)
 + cell_idx += 1
 +# ==================================
 +# fill the fixtures list by dimmer
 +# ==================================
 +cell_idx = 2
 +for k,v in fixtures_list_by_dimmer.items():
 + for fixture in fixtures_list_by_dimmer[k]:
 + dimmer_cell = "A"+ str(cell_idx)
 + channel_cell = "B"+ str(cell_idx)
 + type_cell = "C"+ str(cell_idx)
 + gel_cell = "D"+ str(cell_idx)
 + label_cell = "E"+ str(cell_idx)
 + fixtures_list_by_dimmer_sheet.set(dimmer_cell, str(fixture.getPropertyByName("Dimmer")))
 + fixtures_list_by_dimmer_sheet.set(channel_cell, str(fixture.getPropertyByName("Channel")))
 + fixtures_list_by_dimmer_sheet.set(type_cell, fixture.getPropertyByName("Gel"))
 + fixtures_list_by_dimmer_sheet.set(gel_cell, fixture.getPropertyByName("FixtureType"))
 + fixtures_list_by_dimmer_sheet.set(label_cell, fixture.Label)
 + cell_idx += 1
 +doc.recompute()
 +</sxh>
 +{{tag>freecad python}}
freecad.1616502192.txt.gz · Last modified: (external edit)