Python Group list with pointers rather than names.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Python Group list with pointers rather than names.
Okay when implementing a Part::FeaturePython or App::FeaturePython
I can add a group
newobj = existingObj.newObject("App::DocumentObjectGroupPython",name)
and can add objects to the list, but all names have to be unique within the document i.e. FreeCAD appends three digits to the end if not unique
Is there a way to create a list that just points to existing objects
I can add a group
newobj = existingObj.newObject("App::DocumentObjectGroupPython",name)
and can add objects to the list, but all names have to be unique within the document i.e. FreeCAD appends three digits to the end if not unique
Is there a way to create a list that just points to existing objects
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: Python Group list with pointers rather than names.
Not exactly sure what you mean, but it seems like:
would do it?
Code: Select all
obj_list = []
obj_list.append(existingObj.newObject("App::DocumentObjectGroupPython",name))
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Python Group list with pointers rather than names.
Will try to clarify
Trying to improve my handling of GDML materials.
Here is a screen shot of an example. If you look at the Element Enriched Uranium it has a list of two isotopes each with a fraction value if you expand each item.
The Isotopes in the Isotopes list each have their own properties,
At the moment the list for the Rnriched Uranium has names which FreeCAD has add a unique number so they don't duplicate
those in the Isotope list
Trying to improve my handling of GDML materials.
Here is a screen shot of an example. If you look at the Element Enriched Uranium it has a list of two isotopes each with a fraction value if you expand each item.
The Isotopes in the Isotopes list each have their own properties,
At the moment the list for the Rnriched Uranium has names which FreeCAD has add a unique number so they don't duplicate
those in the Isotope list
Re: Python Group list with pointers rather than names.
Uhmmmmmkeithsloan52 wrote: ↑Thu Apr 09, 2020 3:59 pm Element Enriched Uranium it has a list of two isotopes
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Python Group list with pointers rather than names.
From a sample file, not who created.Kunda1 wrote: ↑Thu Apr 09, 2020 4:21 pmUhmmmmmkeithsloan52 wrote: ↑Thu Apr 09, 2020 3:59 pm Element Enriched Uranium it has a list of two isotopes
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: Python Group list with pointers rather than names.
If I understand you correctly, then, you want to duplicate the isotopes in the sublist merely as links to the original objects, and not separate objects in themselves?
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Python Group list with pointers rather than names.
Note quite.Joel_graff wrote: ↑Thu Apr 09, 2020 6:31 pm If I understand you correctly, then, you want to duplicate the isotopes in the sublist merely as links to the original objects, and not separate objects in themselves?
The xml file being parsed has things like the following
Code: Select all
<isotope name="U235" Z="92" N="235"> <atom type="A" value="235.01"/>
</isotope>
<isotope name="U238" Z="92.0" N="238"> <atom type="A" value="238.03"/>
</isotope>
<element name="enriched_Uranium">
<fraction ref="U235" n="0.9"/>
<fraction ref="U238" n="0.1"/>
</element>
<element name="Hydrogen" formula="H" Z="1."> <atom value="1.01"/>
</element>
<element name="Oxygen" formula="O" Z="8." N="8"> <atom value="16.0"/>
<material name="Water" formula="H20">
<D value="1.0"/>
<composite n="2" ref="Hydrogen"/>
<composite n="1" ref="Oxygen"/>
</material>
<material name="Air">
<D value="1.290" unit="mg/cm3"/>
<fraction n="0.7" ref="Nitrogen"/>
<fraction n="0.3" ref="Oxygen"/>
</material>
I have tried creating objects and then trying to update the label but with only limited success.
- Joel_graff
- Veteran
- Posts: 1949
- Joined: Fri Apr 28, 2017 4:23 pm
- Contact:
Re: Python Group list with pointers rather than names.
Quick question:
Have you checked the "Allow duplicate object labels in one document" preference in General->Document->Document Objects?
Have you checked the "Allow duplicate object labels in one document" preference in General->Document->Document Objects?
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Python Group list with pointers rather than names.
Thanks that is a good shout.Joel_graff wrote: ↑Thu Apr 09, 2020 8:04 pm Quick question:
Have you checked the "Allow duplicate object labels in one document" preference in General->Document->Document Objects?
Will need to research if there is a way to check if the option is set when I run an export so that I can check whether to remove the appended numbers or not.
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Python Group list with pointers rather than names.
Just tried setting the option. Restarted FreeCAD (freecad-daily) and the repeated names still have numbers appended.Joel_graff wrote: ↑Thu Apr 09, 2020 8:04 pm Quick question:
Have you checked the "Allow duplicate object labels in one document" preference in General->Document->Document Objects?