Bonjour
1: je voudrais savoir comment obtenir le nom d'un objet, pas si c'est un " Line " ou " Circle " mais le nom affiché dans la Vue combinée même après renommage
2: je voudrais savoir aussi si on peut donner un nom à un objet que l'on crée Line, Circle ... dé sa création dans un script comme pour les notes.
merci
mario
[Python] Afficher le nom d'un objet
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
[Python] Afficher le nom d'un objet
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: [Python] Afficher le nom d'un objet
Bonjour
j'ai trouvé une alternative avec le Sketcher
mais je suis toujours preneur pour les autres solutions du premier post.
merci
mario
j'ai trouvé une alternative avec le Sketcher
Code: Select all
App.activeDocument().addObject('Sketcher::SketchObject','Nom_Au_Choix')
App.ActiveDocument.Nom_Au_Choix.addGeometry(Part.Line(App.Vector(-10,0.0,0.0),App.Vector(20.0,0.0,0.0)))
App.ActiveDocument.recompute()
merci
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: [Python] Afficher le nom d'un objet
Bonjour
Ce code permet d'afficher tous les objets du projet.
mais dans la feuille de mise en plan, les pages sont nommées par
Ortho (TopView)
Ortho001 (FrontView)
Ortho002 (RightView)
comment afficher le nom que l'on voit dans la Vue Combinée c'est à dire , TopView, FrontView, RightView
merci
mario
Solution
.Label = TopView (nom modifiable)
.Name = Ortho (nom interne non modifiable)
in the macro you use .Name
Not .Label
[edit 30/12/2013] ajout de la solution !
Ce code permet d'afficher tous les objets du projet.
Code: Select all
# -*- coding: utf-8 -*-
#liste les objets du projet en cours
objs = FreeCAD.ActiveDocument.Objects
#print objs
for obj in objs:
name = obj.Name
print name # Affiche le nom de l'objet
# doc.removeObject(name) # Efface l'objet
Ortho (TopView)
Ortho001 (FrontView)
Ortho002 (RightView)
comment afficher le nom que l'on voit dans la Vue Combinée c'est à dire , TopView, FrontView, RightView
merci
mario
Solution
.Label = TopView (nom modifiable)
.Name = Ortho (nom interne non modifiable)
Code: Select all
>sel = FreeCADGui.Selection.getSelection()
>object_Label = sel[0].Label
>object_Name = sel[0].Name
>print object_Label
Line_205
>print object_Name
Line005002001002005003004021
Code: Select all
>>> FreeCADGui.getDocument("pente03").getObject("Line005002001002005003004021").LineColor = (0.03137255,0.38039216,0.58039218)
Code: Select all
>>> FreeCADGui.getDocument("pente03").getObject("Line_205").LineColor = (0.03137255,0.38039216,0.58039218)
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'LineColor'
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.