I'm able to get id's of selected items with
for id in self.options.ids: inkex.utils.debug(id)
I'm trying to get all path in the scene, but i have id's and not label namesfor node in self.svg: if node.label == 'color_fill': for shape in node: inkex.utils.debug(shape.label)
for node in self.svg: if node.label == 'color_fill': for shape in node: inkex.utils.debug(shape.label)
label works, but I only have id strings.I also tried self.svg.xpath('//svg:paths') but i'm having similar trouble.
Elements in Inkscape will always have ids, but not always a separate label unless you have renamed them in the object browser.
my_objects = self.svg.selected for my_object in my_objects: my_id = my_object.label my_label = my_object.get('inkscape:label') inkex.errormsg(f'ID : {my_id} Label : {my_label}')
I wasn't able to get that to work.
The first example here is the id's when all the objects are selected.
The next two don't seem to work, regardless of selction
---------------------------------------------------------------------------
eye_2_R eye_2_L mouth_2 tongue_2 hair_1_L tongue_1 hair_1_R nose_1 mouth_1 eye_1_L eye_1_R robes_1 hand_1_R face_1 brain face_2 wing_1_L halo_2 wing_2_L halo_1 wing_1_R CLIP_angel_1 CLIP_angel_2 CLIP_heavens CLIP_text_2 CLIP_text_1 CLIP_text_3 CLIP_text_7 CLIP_text_8 CLIP_text_4 CLIP_text_5 CLIP_text_6 Untitled 5_2.svg /home/me/comics/artwork/crops/dream/dream_04/svg
ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : robes_1 Label : robes_1 ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : wing_2_L Label : wing_2_L ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None ID : None Label : None CLIP_text_2 CLIP_text_1 CLIP_text_3 CLIP_text_7 CLIP_text_8 CLIP_text_4 CLIP_text_5 CLIP_text_6 Untitled 5_2.svg /home/me/comics/artwork/crops/dream/dream_04/svg
for node in self.svg: if node.label == 'color_fill': for shape in node: inkex.utils.debug(shape.get('inkscape:label'))
None None None None None wing_2_L None None None None None None robes_1 None None None None None None None None None None None CLIP_text_2 CLIP_text_1 CLIP_text_3 CLIP_text_7 CLIP_text_8 CLIP_text_4 CLIP_text_5 CLIP_text_6 Untitled 5_2.svg /home/me/comics/artwork/crops/dream/dream_04/svg
Whoops sorry, I pasted the wrong piece of code.
my_objects = self.svg.selected for my_object in my_objects: my_id = my_object.get_id() my_label = my_object.label inkex.errormsg(f'ID : {my_id} Label : {my_label}')
Working beautifully, thank you.
I'm able to get id's of selected items with
for id in self.options.ids:
inkex.utils.debug(id)
I'm trying to get all path in the scene, but i have id's and not label names
for node in self.svg:
if node.label == 'color_fill':
for shape in node:
inkex.utils.debug(shape.label)
label works, but I only have id strings.
I also tried self.svg.xpath('//svg:paths') but i'm having similar trouble.
Elements in Inkscape will always have ids, but not always a separate label unless you have renamed them in the object browser.
I wasn't able to get that to work.
The first example here is the id's when all the objects are selected.
The next two don't seem to work, regardless of selction
---------------------------------------------------------------------------
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Whoops sorry, I pasted the wrong piece of code.
Working beautifully, thank you.