<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi William,<div class=""><br class=""></div><div class=""> I've made it so when you open a ChimeraX marker file (*.cmm) it will save the extra attributes (the marker_extra_attributes dictionary) in subsequently saved sessions. This will be in tonight's ChimeraX builds. If you need this to work in older ChimeraX (e.g version 1.2.5) then you can call</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>marker_set.save_marker_attribute_in_sessions('marker_extra_attributes', None)<br class=""><div><br class=""></div><div>with the attribute type as None. Probably an attribute type of dict would work too. I don't know what your Dict[str, str] is -- that is not legal Python as far as I know. You can detect when new models are opened and look for marker sets using the add models trigger as described here</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre"> </span><a href="https://www.rbvi.ucsf.edu/chimerax/docs/devel/well_known_triggers.html" class="">https://www.rbvi.ucsf.edu/chimerax/docs/devel/well_known_triggers.html</a></div><div><br class=""></div><div>although that should not be needed for your use starting with tomorrow's daily build. We plan to release ChimeraX 1.3 next month and it will have today's improvements.</div><div><br class=""></div><div> Tom</div><div><br class=""></div><div><br class=""></div><div>On Sep 22, 2021, at 5:21 AM, William Hofsøy via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu" class="">chimerax-users@cgl.ucsf.edu</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi again! Thank you for all the answers from last time. It was very helpful.</div><div class=""><br class=""></div><div class="">I have another question. I was trying to save extra attributes on a marker model from a cmm file and ran into some issues.</div><div class=""><br class=""></div><div class="">I made a function to test it out using:</div><div class="">
<span style="white-space:pre-wrap" class=""></span>marker_set.save_marker_attribute_in_sessions('marker_extra_attributes', Dict[str, str])
</div><div class=""><br class=""></div><div class="">and got an error:<br class=""><div style="margin: 0px; text-indent: 0px; white-space: pre-wrap;" class="">ValueError: error processing: 'attribute registration' -> : No bundle information for typing._GenericAlias<br class=""><br class="">File "C:\Program Files\ChimeraX 1.2.5\bin\lib\site-packages\chimerax\core\session.py", line 262, in discovery<br class="">raise ValueError("error processing: %s: %s" % (_obj_stack(parents, obj), e))<br class=""></div><div style="margin: 0px; text-indent: 0px; white-space: pre-wrap;" class=""><br class=""><span style="font-style:italic" class=""></span></div><div style="margin: 0px; text-indent: 0px; white-space: pre-wrap;" class="">Is it only possible to save more primitive types or can I fix this somehow?</div><div style="margin: 0px; text-indent: 0px; white-space: pre-wrap;" class=""><br class=""></div><div style="margin: 0px; text-indent: 0px; white-space: pre-wrap;" class="">In my project the cmm files contain extra attributes that my plugin makes use of. These are the attributes that I would like to save in sessions.</div><div style="margin: 0px; text-indent: 0px; white-space: pre-wrap;" class="">I would like this save enabling function to be called automatically when a cmm file is opened so that I can enable saving of these attributes on file open.</div><div style="margin: 0px; text-indent: 0px; white-space: pre-wrap;" class="">Is there perhaps some onFileOpened that I could subscribe to, or is there another way that could allow me to achieve this?</div><div style="margin: 0px; text-indent: 0px; white-space: pre-wrap;" class=""><br class=""></div><div style="margin: 0px; text-indent: 0px; white-space: pre-wrap;" class="">-William<br class=""></div><p style="margin:0px;text-indent:0px;white-space:pre-wrap" class=""><span style="font-style:italic" class=""></span></p></div><div class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">fre. 27. aug. 2021 kl. 22:15 skrev Tom Goddard <<a href="mailto:goddard@sonic.net" class="">goddard@sonic.net</a>>:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class="">Hi William,<div class=""><br class=""></div><div class=""> To add a marker to an open marker set:</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class=""> </span>from chimerax.markers import MarkerSet</div><div class=""><span style="white-space:pre-wrap" class=""> </span>marker_sets = session.models.list(type = MarkerSet)</div><div class=""><span style="white-space:pre-wrap" class=""> </span>m = marker_sets[0]</div><div class=""><span style="white-space:pre-wrap" class=""> </span>xyz = (15.3, -34, 8.8)</div><div class=""><span style="white-space:pre-wrap" class=""> </span>color = (255,0,0,255) # RGBA 0-255 range.</div><div class=""><span style="white-space:pre-wrap" class=""> </span>radius = 2.5</div><div class=""> m.create_marker(xyz, color, radius)</div><div class=""><br class=""></div><div class="">I see MarkerSet is not in our online programming documentation yet. The source code is in your ChimeraX distribution under</div><div class=""><br class=""></div><div class=""> chimerax/lib/python3.9/site-packages/chimerax/markers/markers.py</div><div class=""><div class=""><br class=""></div><div class="">or on GitHub</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class=""> </span><a href="https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/markers/src/markers.py" target="_blank" class="">https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/markers/src/markers.py</a></div><div class=""><br class=""></div><div class="">The marker_extra_attributes is saved and restored in cmm files. For ChimeraX session files you can get extra attributes to save by saying what attributes you want saved</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class=""> </span>marker_set.save_marker_attribute_in_sessions('myattribute', float)</div><div class=""><br class=""></div><div class=""> For placing geometric surfaces in the scene look at the shape command</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class=""> </span><a href="https://www.cgl.ucsf.edu/chimerax/docs/user/commands/shape.html" target="_blank" class="">https://www.cgl.ucsf.edu/chimerax/docs/user/commands/shape.html</a></div><div class=""><br class=""></div><div class="">Surprised there is no cube shape, but maybe rectangle with the slab option can make a cube. Python code is here</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class=""> </span><a href="https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/shape/src/shape.py" target="_blank" class="">https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/shape/src/shape.py</a></div><div class=""><br class=""></div><div class="">for example</div><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class=""> </span>from chimerax.shape.shape import shape_rectangle</div><div class=""><span style="white-space:pre-wrap" class=""> </span>model = shape_rectangle(session, width = 10, height = 10, slab = (-5,5), mesh = True)</div><div class=""><br class=""></div><div class=""> Tom</div><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Aug 27, 2021, at 8:21 AM, William Hofsøy via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu" target="_blank" class="">chimerax-users@cgl.ucsf.edu</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="">Hi, I'm currently working on a plugin that deals with a cmm-file model and have a few questions about how to do certain things. Mainly I would like to be able to modify the model by adding new markers and links to the model. I have managed to figure out how to make new markersets and add them to the session but not how to alter existing ones aka the model that I load from the cmm file.</div><div class="">Additionally I am making use of the marker_extra_attributes info since the cmm file im reading has attributes there that I need, but as I read in the documentation these aren't saved in sessions and I wondered if there is a way to do just that.<br class=""></div><div class="">Lastly, I was wondering if it is possible to place any mesh in the scene, for instance a cube.</div><div class=""><br class=""></div><div class="">-William<br class=""></div></div>
_______________________________________________<br class="">ChimeraX-users mailing list<br class=""><a href="mailto:ChimeraX-users@cgl.ucsf.edu" target="_blank" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">Manage subscription:<br class=""><a href="https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users" target="_blank" class="">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div></div></div>
_______________________________________________<br class="">ChimeraX-users mailing list<br class=""><a href="mailto:ChimeraX-users@cgl.ucsf.edu" class="">ChimeraX-users@cgl.ucsf.edu</a><br class="">Manage subscription:<br class="">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users<br class=""></div></blockquote></div><br class=""></div></body></html>