diff --git a/asset/doc/montchg_doc-fr.blend b/asset/doc/montchg_doc-fr.blend new file mode 100644 index 0000000..38b72d9 Binary files /dev/null and b/asset/doc/montchg_doc-fr.blend differ diff --git a/asset/doc/porcou_doc-fr.blend b/asset/doc/porcou_doc-fr.blend new file mode 100644 index 0000000..db3ed54 Binary files /dev/null and b/asset/doc/porcou_doc-fr.blend differ diff --git a/asset/doc/twin_doc-gen.py b/asset/doc/twin_doc-gen.py new file mode 100644 index 0000000..84e502f --- /dev/null +++ b/asset/doc/twin_doc-gen.py @@ -0,0 +1,287 @@ +import bpy # Blender +import importlib +import sys +import time + +############################################################################### +# twin_doc-gen.py +# @title: Script (bpy) de génération de la documentation statique de l'environnement 3D pour jumeau numérique +# @project: Blender-EduTech +# @lang: fr +# @authors: Philippe Roy +# @copyright: Copyright (C) 2022 Philippe Roy +# @license: GNU GPL +############################################################################### + +# UPBGE scene +scene = bpy.context.scene +# scene=bpy.data.scenes["Scene"] + +# Cards description +card_description ={} + +# Documentation du sytème +path = scene.objects['Doc']['path'] +name = scene.objects['Doc']['system']+'_doc' +spec = importlib.util.spec_from_file_location(name, path) +system = importlib.util.module_from_spec(spec) +sys.modules[spec.name] = system +spec.loader.exec_module(system) +# system=importlib.import_module(scene.objects['Doc']['system']+'_doc') # Système +system_card = system.get_system_card() +card_description.update(system.get_card_description()) + +############################################################################### +# Documentation Python +############################################################################### + +# "oop-card" +python_card=["function-card", "alternative-card", "loop-card", "flow-card", "text-card", "list-card", "dict-card", "console-card", "sleep-card", "python-card"] +#python_card=["function-card"] +# python_card=["function-card" ,"alternative-card"] + +# Fonction +card_function_title="Fonction" +card_function_text=" La définition d\"une fonction se fait avec \n \'def\'. La fonction peut renvoyer une \n valeur avec \'return\'. \n\n" +card_function_text=card_function_text + " def fonction_1 (arguments) : \n instruction_1 \n instruction_2 \n ....\n return valeurs_renvoyées \n\n" +card_function_text=card_function_text + " Les arguments sont des données \n transmises à la fonction." +card_function_url=[["w3schools.com : functions","https://www.w3schools.com/python/python_functions.asp"]] +card_description.update({"function-card" : [card_function_title, card_function_text, card_function_url]}) + +# Alternative +card_alternative_title="Alternative" +card_alternative_text=" L\"alternative permet d\"éxécuter des \n instructions en fonction d\"un test. \n" +card_alternative_text=card_alternative_text + " Elle se programme en suivant la suite : \n \'if \' (si) ... \'else\' (sinon) ... \n\n" +card_alternative_text=card_alternative_text + " if condition :\n" +card_alternative_text=card_alternative_text + " instruction_1\n" +card_alternative_text=card_alternative_text + " else : \n" +card_alternative_text=card_alternative_text + " instruction_2\n\n" +card_alternative_text=card_alternative_text + "Le \'else\' (sinon) est facultatif." +card_alternative_url=[["w3schools.com : if ... else","https://www.w3schools.com/python/python_conditions.asp"]] +card_description.update({"alternative-card" : [card_alternative_title, card_alternative_text, card_alternative_url]}) + +# Boucles +card_loop_title="Boucles" +card_loop_text=" Il y a deux types de boucle : \n - avec \'for\' pour définir un nombre de \n répétition (ici n), \n - avec \'while\' (tant que) pour prendre \n en compte une condition. \n \n" +card_loop_text=card_loop_text + " for i in range (n) : \n instruction \n \n" +card_loop_text=card_loop_text + " while condition : \n instruction" +card_loop_url=[["w3schools.com : for","https://www.w3schools.com/python/python_for_loops.asp"], + ["w3schools.com : while","https://www.w3schools.com/python/python_while_loops.asp"]] +card_description.update({"loop-card" : [card_loop_title, card_loop_text, card_loop_url]}) + +# Flux +card_flow_title="Contrôle du flux" +card_flow_text=""" Les structures (if, while, for) peuvent \n être gérées plus finement par les \n fonctions 'break', 'continue' et 'pass'. \n + - 'break' : termine l"itération en cours et \n arrête la boucle. + - 'continue' : termine l"itération en cours et \n reprend la boucle. + - 'pass' : instruction vide.""" +card_flow_url=[["w3schools.com : break","https://www.w3schools.com/python/ref_keyword_break.asp"], + ["w3schools.com : continue","https://www.w3schools.com/python/ref_keyword_break.asp"], + ["w3schools.com : pass","https://www.w3schools.com/python/ref_keyword_pass.asp"]] +card_description.update({"flow-card" : [card_flow_title, card_flow_text, card_flow_url]}) + +# Chaîne de caractères +card_text_title="Chaîne de caractères" +card_text_text=""" Une chaîne de caractères correspond à un \n texte (mot, phrase). Elle est délimitée \n par " ou ' : texte = 'Bonjour ! ' \n +- texte1 + texte2 : concaténe plusieurs \n chaînes. +- len(texte) : renvoie la longueur de texte. +- "\\n" : caractère aller à la ligne. +- texte[i] : renvoie le caractère du rang i de \n texte (commence à 0). +- texte[2:5] : renvoie les caractères du rang \n 2 au rang 5. +- texte.replace("a","b") : remplace les "a" en "b". """ +card_text_url=[ + ["Doc. Python v3 Français : string","https://docs.python.org/fr/3/library/string.html"], + ["w3schools.com : strings","https://www.w3schools.com/python/python_strings.asp"]] +card_description.update({"text-card" : [card_text_title, card_text_text, card_text_url]}) + +# Liste +card_list_title="Liste" +card_list_text=""" Une liste est une séquence d"éléments. \n Elle est délimitée par des crochets : + liste = ['pomme', 7, 'rouge', True] \n +- liste[i] : renvoie l"élément du rang i de la \n liste (commence à 0). +- liste.append('neige') : ajoute 'neige' à la \n fin de la liste. +- len(liste) : renvoie le nombre d"éléments. +- liste.sort() : classe par ordre croissant la \n liste (alphabétiquement / numériquement). +- liste.remove('rouge') : enlève la première \n occurence de la valeur.""" +card_list_url=[ + ["Doc. Python v3 Français : list","https://docs.python.org/fr/3/library/stdtypes.html#sequence-types-list-tuple-range"], + ["w3schools.com : lists","https://www.w3schools.com/python/python_lists.asp"]] +card_description.update({"list-card" : [card_list_title, card_list_text, card_list_url]}) + +# Dictionnaire +card_dict_title="Dictionnaire" +card_dict_text=""" Une liste est une collection d"éléments. \n Elle est délimitée par des accolades, \n chaque valeur comporte une clé unique : + dico = {'nom' : 'Haddock', 'prénom' : \n 'Archibald', 'année' : 1940} \n +- dico[clé] : renvoie la valeur liée à la clé. +- dico.update('domicile' : 'Moulinsart') : met \n à jour les paires de clé/valeur. +- len(dico) : renvoie le nombre d"éléments. +- list(dico) : renvoie la liste des clés. +- dico.pop("année") : enlève la valeur associée \n à la clé.""" +card_dict_url=[ + ["Doc. Python v3 Français : dict","https://docs.python.org/fr/3/library/stdtypes.html#mapping-types-dict"], + ["w3schools.com : dictionaries","https://www.w3schools.com/python/python_dictionaries.asp"]] +card_description.update({"dict-card" : [card_dict_title, card_dict_text, card_dict_url]}) + +# Objet (POO) +card_oop_title="Programmation\norientée objet (POO)" +card_oop_text="\nFIXME" +card_oop_url=[["w3schools.com : classes & objects","https://www.w3schools.com/python/python_classes.asp"]] +card_description.update({"oop-card" : [card_oop_title, card_oop_text, card_oop_url]}) + +# Console +card_console_title="Console" +card_console_text=" Si vous avez executé Ropy dans un \n terminal (avec l\"option \'-con\'), vous \n pouvez utiliser le terminal comme \n console de debuggage.\n\n" +card_console_text= card_console_text + " print(\'Bonjour !\') \n -> Affiche le texte dans la console.\n\n" +card_console_text= card_console_text + " variable = input () \n -> Permet la saisie, par exemple : \n" +card_console_text= card_console_text + " entree = \'\'\n while entree == \'\' :\n entree = input ()" +card_console_url=[["w3schools.com : print","https://www.w3schools.com/python/ref_func_print.asp"], + ["w3schools.com : input","https://www.w3schools.com/python/ref_func_input.asp"]] +card_description.update({"console-card" : [card_console_title, card_console_text, card_console_url]}) + +# Temps +card_sleep_title="Gestion du temps" +card_sleep_text=" Vous pouvez créer des temporisations \n dans le déroulement du script.\n\n" +card_sleep_text= card_sleep_text + " time.sleep(x) \n -> Marque d\"un temps d\"arrêt de \n x secondes.\n\n" +card_sleep_text= card_sleep_text + " Il faudra préalablement importer la \n bibliothèque \'time\' avec \'import time\'." +card_sleep_url=[["Doc. Python v3 Fr : sleep","https://docs.python.org/fr/3/library/time.html#time.sleep"]] +card_description.update({"sleep-card" : [card_sleep_title, card_sleep_text, card_sleep_url]}) + +# Python +card_python_title="Langage Python" +card_python_text=""" Le Python est un langage de programmation \n interprété open source. Python vise à être \n visuellement épuré avec une syntaxe \n clairement séparée des mécanismes de \n bas niveau.\n + Python possède beaucoup de bibliothèques \n spécialisées. Multiplateformes et \n multiparadigme, il est utilisé dans de \n nombreux contextes : scriptage, calcul \n numérique, prototypage, enseignement, \n ou encore comme langage de commande \n pour de nombreux logiciels.""" + +card_python_url=[["python.org","https://python.org"], ["AFPy","https://www.afpy.org"]] +card_description.update({"python-card" : [card_python_title, card_python_text, card_python_url]}) + +############################################################################### +# Génération statique des pages (fichiers *_doc-fr.blend) +############################################################################### + +# Sortir de la génération +def text_gene_end(): + print ("Génération des pages effectuée.") + # print ("Génération des pages effectuée.") + # for item in scene.objects: + # print (item.name) + +# Génération des pages +def text_gene(obj): + print ("Génération des pages de la documentation pour le chapitre : "+ obj.name +" ...") + if obj.name == "Doc_chap-system": + chap_card = system_card + rep_chap= bpy.data.objects["Doc_chap-system"] + if obj.name == "Doc_chap-python": + chap_card = python_card + rep_chap= bpy.data.objects["Doc_chap-python"] + + # Création des objets 3D + # bpy.ops.collection.create(name='Collection') + i=1 + for card in chap_card : + print ("Génération de la page : "+ card) + + # Repère page + rep_ref= bpy.data.objects["Doc_chap-ref"] + rep_page = duplicateObject(scene, "Doc_page-"+str(card), "Doc_chap-ref",rep_chap.location.x+ i*100, rep_chap.location.y, rep_chap.location.z) + collection = bpy.data.collections["Doc generation"] + collection_old = bpy.data.collections["Doc"] + collection.objects.link(rep_page) + collection_old.objects.unlink(rep_page) + i+=1 + + # Titre + titre_name = "Doc_title-"+str(card) + titre_ref=bpy.data.objects["Doc_title-ref"] + titre = addText(scene, titre_name, "Doc_title-ref", card_description[card][0], + titre_ref.location.x-rep_ref.location.x, + titre_ref.location.y-rep_ref.location.y, + titre_ref.location.z-rep_ref.location.z) + titre.parent = rep_page + collection.objects.link(titre) + collection_old.objects.unlink(titre) + + # Texte de la page en une seule fois + ligne_name = "Doc_text-"+str(card) + ligne_ref=bpy.data.objects["Doc_text-l1-ref"] + ligne_text = addText(scene, ligne_name, "Doc_text-l1-ref", card_description[card][1], + ligne_ref.location.x-rep_ref.location.x, + ligne_ref.location.y-rep_ref.location.y, + ligne_ref.location.z-rep_ref.location.z) + # bpy.data.collections["Doc generation"].objects.link(ligne_text) + ligne_text.parent = rep_page + collection.objects.link(ligne_text) + collection_old.objects.unlink(ligne_text) + + # Texte de la page découpé + # lines = card_description[card][1].split("\n") + # for j in range (13): + # ligne_name = "Doc_text-l"+str(j+1)+"-"+str(card) + # ligne_ref=bpy.data.objects["Doc_text-l"+str(j+1)+"-ref"] + # # ligne_ref.data.body="A" + # if j >= len(lines): + # pass + # else: + # if len(lines[j]) ==0: + # pass + # else: + # ligne_text = addText(scene, ligne_name, "Doc_text-l"+str(j+1)+"-ref", lines[j], + # ligne_ref.location.x-rep_ref.location.x, + # ligne_ref.location.y-rep_ref.location.y, + # ligne_ref.location.z-rep_ref.location.z) + # bpy.data.collections["Doc generation"].objects.link(ligne_text) + # ligne_text.parent = rep_page + # # for obj_selected in bpy.context.selected_objects: + # # obj_selected.select_set(False) + # # bpy.ops.object.join() + + # Fin + print ("Génération des pages de la documentation pour le chapitre : "+ obj.name +" Ok") + +############################################################################### +# Bas niveau duplication d'objet +############################################################################### + +# Copier un object + +def duplicateObject (scene, name, src, x, y, z) : + for obj in bpy.context.selected_objects: + obj.select_set(False) + bpy.data.objects[src].select_set(True) + bpy.ops.object.duplicate() + for obj in bpy.context.selected_objects: + break + obj.name = name + obj.scale = bpy.data.objects[src].scale + obj.location = (x,y,z) + return obj + +# Créer un texte + +def addText (scene, name, src, body, x, y, z) : + curve = duplicateObject(scene, name, src, x, y, z) + curve.data.body=body + return curve + +# Créer un maillage texte + +def addTextMesh (scene, name, src, body, x, y, z) : + curve = duplicateObject(scene, name, src, x, y, z) + curve.data.body=body + mesh = bpy.data.meshes.new_from_object(curve) + obj = bpy.data.objects.new(name, mesh) + obj.matrix_world = curve.matrix_world + for obj_selected in bpy.context.selected_objects: + obj_selected.select_set(False) + curve.select_set(True) + bpy.ops.object.delete() + obj.name = name + return obj + +############################################################################### +# Main +############################################################################### + +text_gene(scene.objects["Doc_chap-system"]) +text_gene(bpy.data.objects["Doc_chap-python"]) +text_gene_end() diff --git a/asset/doc/volrou_doc-fr.blend b/asset/doc/volrou_doc-fr.blend new file mode 100644 index 0000000..8305766 Binary files /dev/null and b/asset/doc/volrou_doc-fr.blend differ diff --git a/monte_charge/montchg_doc-fr.blend b/monte_charge/montchg_doc-fr.blend new file mode 100644 index 0000000..5a24ab8 Binary files /dev/null and b/monte_charge/montchg_doc-fr.blend differ diff --git a/monte_charge/monte_charge-4.blend b/monte_charge/monte_charge-4.blend index 4b1b84f..de25dcd 100644 Binary files a/monte_charge/monte_charge-4.blend and b/monte_charge/monte_charge-4.blend differ diff --git a/monte_charge/twin_doc-gen.py b/monte_charge/twin_doc-gen.py new file mode 120000 index 0000000..0e14dac --- /dev/null +++ b/monte_charge/twin_doc-gen.py @@ -0,0 +1 @@ +/home/phroy/Bureau/seriousgames/blender-edutech/git/digital_twin/twin_doc-gen.py \ No newline at end of file diff --git a/poppy_ergo_jr/twin_doc-gen.py b/poppy_ergo_jr/twin_doc-gen.py new file mode 120000 index 0000000..0e14dac --- /dev/null +++ b/poppy_ergo_jr/twin_doc-gen.py @@ -0,0 +1 @@ +/home/phroy/Bureau/seriousgames/blender-edutech/git/digital_twin/twin_doc-gen.py \ No newline at end of file diff --git a/portail_coulissant/porcou_doc-fr.blend b/portail_coulissant/porcou_doc-fr.blend index f40f145..76ce2ae 100644 Binary files a/portail_coulissant/porcou_doc-fr.blend and b/portail_coulissant/porcou_doc-fr.blend differ diff --git a/portail_coulissant/portail_coulissant-16.blend b/portail_coulissant/portail_coulissant-16.blend index 9dfa219..745dc66 100644 Binary files a/portail_coulissant/portail_coulissant-16.blend and b/portail_coulissant/portail_coulissant-16.blend differ diff --git a/portail_coulissant/portail_coulissant-17.blend b/portail_coulissant/portail_coulissant-17.blend new file mode 100644 index 0000000..e3985ce Binary files /dev/null and b/portail_coulissant/portail_coulissant-17.blend differ diff --git a/portail_coulissant/portail_coulissant-18.blend b/portail_coulissant/portail_coulissant-18.blend new file mode 100644 index 0000000..fa892a1 Binary files /dev/null and b/portail_coulissant/portail_coulissant-18.blend differ diff --git a/twin.py b/twin.py index ba37a7e..ddeff05 100644 --- a/twin.py +++ b/twin.py @@ -150,8 +150,6 @@ def cmd_init(): windows=("Doc", "Doc_chap-general", "Doc_chap-system", "Doc_chap-python", "About") for window in windows: scene.objects[window].setVisible(False,True) - twin_doc.init_hide() - # twin_doc.init() ## # Highlight des commandes diff --git a/twin_config.xml b/twin_config.xml index 2556109..be2c49a 100644 --- a/twin_config.xml +++ b/twin_config.xml @@ -1,7 +1,7 @@ - 1458 - 820 + 1359 + 764 1 \ No newline at end of file diff --git a/twin_doc-gen.py b/twin_doc-gen.py index c3efa9a..4b6982a 100644 --- a/twin_doc-gen.py +++ b/twin_doc-gen.py @@ -184,8 +184,8 @@ def text_gene(obj): # Repère page rep_ref= bpy.data.objects["Doc_chap-ref"] rep_page = duplicateObject(scene, "Doc_page-"+str(card), "Doc_chap-ref",rep_chap.location.x+ i*100, rep_chap.location.y, rep_chap.location.z) - # collection = bpy.data.collections["Test"] - # collection.objects.link(rep_page) + collection = bpy.data.collections["Doc generation"] + collection.objects.link(rep_page) i+=1 # Titre diff --git a/twin_doc.py b/twin_doc.py index b5a804f..8fed9e2 100644 --- a/twin_doc.py +++ b/twin_doc.py @@ -1,5 +1,6 @@ import bge # Bibliothèque Blender Game Engine (UPBGE) -# import bpy # Blender +import bpy # Blender +import os import importlib import webbrowser import time @@ -168,14 +169,6 @@ card_description.update({"python-card" : [card_python_title, card_python_text, c # Initialisation de la documentation ## -def init_hide(): - for card in card_description: - scene.objects["Doc_page-"+card].setVisible(False,True) - -## -# Initialisation de la documentation -## - def init(): # UI : information @@ -209,9 +202,11 @@ def init(): scene.objects['Doc_chap-system-url'+str(i)+'-colbox'].suspendPhysics() scene.objects['Doc_chap-system-url'+str(i)].color = color_doc_chap - # Chargement du texte en mode dynamique - if scene.objects['Doc']['static']== False : - text_load() + # Chargement du texte + if scene.objects['Doc']['static']: # en statique + text_static_load() + else: + text_dynamic_load() # en dynamique # Mémorisation de la position des pages for page in chap: @@ -249,7 +244,7 @@ def open(): for i in range (13): scene.objects['Doc_text-l'+str(i+1)+'-ref'].setVisible(False, False) else: - text_hide() + text_dynamic_hide() # Placer le nouveau chapitre name_chap = scene.objects['Doc']['page_chap'] @@ -282,11 +277,11 @@ def open(): name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct'] scene.objects['Doc_title']['Text'] = card_description[name_fct][0] scene.objects['Doc_title'].setVisible(True, False) - text_show(name_fct) + text_dynamic_show(name_fct) else: scene.objects['Doc_title']['Text'] = " " scene.objects['Doc_title'].setVisible(False,True) - text_hide() + text_dynamic_hide() ## # Fermer la documentation @@ -306,6 +301,10 @@ def close(cont): scene.objects["Doc_chap-"+page].worldPosition.y = scene.objects["Doc_chap-"+page]['init_ly'] scene.objects["Doc_chap-"+page].worldPosition.z = scene.objects["Doc_chap-"+page]['init_lz'] scene.objects['Doc'].setVisible(False,True) + for card in card_description: + scene.objects["Doc_page-"+card].setVisible(False,True) + scene.objects["Doc_title-"+card].setVisible(False,True) + scene.objects["Doc_text-"+card].setVisible(False,True) ## # Highlight @@ -403,7 +402,7 @@ def chapter(cont): scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.z = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lz'] scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].setVisible(False,True) else: - text_hide(scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['page_fct']) + text_dynamic_hide(scene.objects["Doc_chap-"+scene.objects['Doc']['page_chap']]['page_fct']) # Placer le nouveau chapitre name_chap= obj.name[4:-7] @@ -441,14 +440,14 @@ def chapter(cont): name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct'] scene.objects['Doc_title']['Text'] = card_description[name_fct][0] scene.objects['Doc_title'].setVisible(True, False) - text_show(name_fct) + text_dynamic_show(name_fct) else: if scene.objects['Doc']['static'] : pass else: scene.objects['Doc_title']['Text'] = " " scene.objects['Doc_title'].setVisible(False,True) - text_hide() + text_dynamic_hide() ## # Afficher les details de la fonction à partir d'une carte @@ -459,36 +458,35 @@ def card (cont): obj = cont.owner name_chap = scene.objects['Doc']['page_chap'] name_fct= obj.name[:-7] + name_old_fct= scene.objects['Doc_chap-'+name_chap]['page_fct'] scene.objects['Doc_title']['Text'] = " " # Enlever l'ancienne carte - if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="": + if name_old_fct !="": if scene.objects['Doc']['static'] : - scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.x = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lx'] - scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.y = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_ly'] - scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.z = scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lz'] - scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].setVisible(False,True) + scene.objects["Doc_page-"+name_old_fct].worldPosition.x = scene.objects["Doc_page-"+name_old_fct]['init_lx'] + scene.objects["Doc_page-"+name_old_fct].worldPosition.y = scene.objects["Doc_page-"+name_old_fct]['init_ly'] + scene.objects["Doc_page-"+name_old_fct].worldPosition.z = scene.objects["Doc_page-"+name_old_fct]['init_lz'] + scene.objects["Doc_page-"+name_old_fct].setVisible(False,True) else: - text_hide(scene.objects['Doc_chap-'+name_chap]['page_fct']) - scene.objects[scene.objects['Doc_chap-'+name_chap]['page_fct']].color = color_doc_fct - scene.objects[scene.objects['Doc_chap-'+name_chap]['page_fct']+'-text'].color = color_doc_fct - scene.objects[scene.objects['Doc_chap-'+name_chap]['page_fct']+'-icon'].color = color_doc_fct + text_dynamic_hide(name_old_fct) + scene.objects[name_old_fct].color = color_doc_fct + scene.objects[name_old_fct+'-text'].color = color_doc_fct + scene.objects[name_old_fct+'-icon'].color = color_doc_fct # Afficher le texte de la carte + print (name_fct) scene.objects['Doc_chap-'+name_chap]['page_fct'] = name_fct scene.objects[name_fct].color = color_doc_activate scene.objects[name_fct+'-icon'].color = color_doc_activate scene.objects[name_fct+'-text'].color = color_doc_activate if scene.objects['Doc']['static'] : - scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lx']=scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.x - scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_ly']=scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.y - scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']]['init_lz']=scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition.z - scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].worldPosition = scene.objects['Doc'].worldPosition - scene.objects["Doc_page-"+scene.objects['Doc_chap-'+name_chap]['page_fct']].setVisible(True,True) + scene.objects["Doc_page-"+name_fct].worldPosition = scene.objects['Doc'].worldPosition + scene.objects["Doc_page-"+name_fct].setVisible(True,True) else: scene.objects['Doc_title']['Text'] = card_description[name_fct][0] scene.objects['Doc_title'].setVisible(True, False) - text_show(name_fct) + text_dynamic_show(name_fct) # URL if name_chap == "system" or name_chap == "python": @@ -523,7 +521,7 @@ def link (cont): # Cacher le texte ## -def text_hide(card=None): +def text_dynamic_hide(card=None): if card is None: for card in card_description: for i in range (13): @@ -536,7 +534,7 @@ def text_hide(card=None): # Afficher le texte ## -def text_show(card=None): +def text_dynamic_show(card=None): if card is None: for card in card_description: for i in range (13): @@ -549,7 +547,7 @@ def text_show(card=None): # Préchargement des textes ## -def text_load(): +def text_dynamic_load(): for i in range (13): scene.objects['Doc_text-l'+str(i+1)+'-ref']['Text'] = "" @@ -571,3 +569,50 @@ def text_load(): scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']="" else: scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=lines[i] + +############################################################################### +# Chargement des pages statiques +############################################################################### + +def text_static_load(): + + # Charger la collection + file_path = "asset/doc/porcou_doc-fr.blend" + inner_path = "Collection" + object_name ="Doc generation" + bpy.ops.wm.append( + filepath=os.path.join(file_path, inner_path, object_name), + directory=os.path.join(file_path, inner_path), + filename=object_name) + scene.convertBlenderCollection(bpy.data.collections[object_name], True) + + # Lier et configurer les objects + for card in card_description: + + # Repère + page_name ="Doc_page-"+card + scene.objects[page_name]['init_lx']=scene.objects[page_name].worldPosition.x + scene.objects[page_name]['init_ly']=scene.objects[page_name].worldPosition.y + scene.objects[page_name]['init_lz']=scene.objects[page_name].worldPosition.z + + # Titre + title_name ="Doc_title-"+card + scene.objects[title_name]. setParent(scene.objects[page_name], True, False) + bpy.data.objects[title_name].data.font=bpy.data.fonts['Espresso Dolce Regular'] + scene.objects[title_name].worldPosition.x += scene.objects[page_name].worldPosition.x + scene.objects[title_name].worldPosition.y += scene.objects[page_name].worldPosition.y + scene.objects[title_name].worldPosition.z += scene.objects[page_name].worldPosition.z + + # Texte + text_name ="Doc_text-"+card + scene.objects[text_name]. setParent(scene.objects[page_name], True, False) + # text_object=scene.objects[text_name].blenderObject.data + # text_object.font=bpy.data.fonts['Espresso Dolce Regular'] # Trop lourd + bpy.data.objects[text_name].data.font=bpy.data.fonts['Bfont Regular'] # Bien plus léger + scene.objects[text_name].worldPosition.x += scene.objects[page_name].worldPosition.x + scene.objects[text_name].worldPosition.y += scene.objects[page_name].worldPosition.y + scene.objects[text_name].worldPosition.z += scene.objects[page_name].worldPosition.z + + scene.objects[page_name].setVisible(False,True) + scene.objects[title_name].setVisible(False,True) + scene.objects[text_name].setVisible(False,True) diff --git a/volet_roulant/twin_doc-gen.py b/volet_roulant/twin_doc-gen.py new file mode 120000 index 0000000..0e14dac --- /dev/null +++ b/volet_roulant/twin_doc-gen.py @@ -0,0 +1 @@ +/home/phroy/Bureau/seriousgames/blender-edutech/git/digital_twin/twin_doc-gen.py \ No newline at end of file diff --git a/volet_roulant/volet_roulant-17.blend b/volet_roulant/volet_roulant-17.blend index e8ca517..1f4b94e 100644 Binary files a/volet_roulant/volet_roulant-17.blend and b/volet_roulant/volet_roulant-17.blend differ diff --git a/volet_roulant/volrou_doc-fr.blend b/volet_roulant/volrou_doc-fr.blend new file mode 100644 index 0000000..272043d Binary files /dev/null and b/volet_roulant/volrou_doc-fr.blend differ