Hey Inkscapers. Hope you're having an awesome day...
Ok, so I've been asked to generate a random root structure type graphic. Fairly thick roots, meandering, over lapping etc. My first thought was to adapt the Tree extension and invert it.
But can't seem to install pturtle as calls to this are making the rtree-debug extension wig out, so not sure if that's been superseded?
So thought, find the Render > Random Tree.. extension copy that and see if I can make it do multiple tress and thicken / separate the paths. Can't seem to find this anywhere so coupla questions, where would I find this script and would this be the best way of generating a tangled root style graphic? Thoughts welcomed!
Kind of… And thanks.. 😊 When I ran the extension it generated “single” / tightly packed root segments. Do we know where I could find the script on Windows as it wasn’t obvious? Ta..
Hi both. Thanks for the input. Always learning... 😊
Which leads me to my next question.. I'm working on an extension (non turtle based) to draw roots and branches, something to get me into writing extensions and working with Python. Odd beast..
So I can generate multiple elements (with specified names / ids) onto a new layer group (with a specified name / id). The loop is "generate element", randomize some variables, generate a new element etc. What I would like to do is generate element, make it branchey / rooty, randomize variables, repeat. What I'm struggling with is how to select path / segment element (by id / by layer to get all?) and make it branchey / rooty. and whether I should generate all elements then do the fancy bit or do the fancy bit after the generation of each element. I'm guessing en masse at the end of the element generation stage would be more efficient.
I'm currently looking to have the py / inx files available via GitHub shortly, but not really used it much and just setting up VS code etc etc.. Have attached for now. Please excuse randomness, happy to accept advice. Happy to explain any of my non coder code if anyone has any thoughts!
Basically, the question is how do I select a path so I can use fractalise or some some pattern to make the elements more root / branch like. Thanks in advance.
If you are the creator of the elements, you can add an id as you create each one. You can also add the id ( or the entire element to a list / dictionary etc ) If you do not assign an id, Inkscape will assign one automatically when the extension finishes running.
groups etc into the function - https://www.w3schools.com/xml/xpath_syntax.asp
Thats just an example, xpath has a lot of options.
or you could loop through finding element.TAG of your choice etc.
For creating the paths, I am not a mathematician
However unless you want to use fractals - there are many types of modified random walks - https://demonstrations.wolfram.com/ConstrainedRandomWalk/
I think that is how the original extension works. Python has a function, random.randrange(lower, upper) generally you would set upper and lower on a curve - fractions of 2 pi Radians.
Hi, thanks for your thoughts, appreciated! Not sure I quite understand, passing back a "selection" to the main Inkscape window but continual reading is leading me to come to the conclusion that Inkscape is "just" an XML (SVG) parser. "just" obviously" doesn't do it justice, but I think it's helping me understand how to manipulate elements.
Haven't touched XPath etc in quite some time, time to get back into it!
I'll check out some of the random walk algorithms and be sure to let you know how it goes! Have a great day all.
Hey Inkscapers. Hope you're having an awesome day...
Ok, so I've been asked to generate a random root structure type graphic. Fairly thick roots, meandering, over lapping etc. My first thought was to adapt the Tree extension and invert it.
I downloaded the Dropbox script on here : https://alpha.inkscape.org/vectors/www.inkscapeforum.com/viewtopic3404-2.html?t=19449
But can't seem to install pturtle as calls to this are making the rtree-debug extension wig out, so not sure if that's been superseded?
So thought, find the Render > Random Tree.. extension copy that and see if I can make it do multiple tress and thicken / separate the paths. Can't seem to find this anywhere so coupla questions, where would I find this script and would this be the best way of generating a tangled root style graphic? Thoughts welcomed!
Enjoy, Cheers, Keith
Maybe this:
In essence the Random Tree won´t make it?
I believe that´s the one you´re searching for in the Inkscape package:
Kind of… And thanks.. 😊 When I ran the extension it generated “single” / tightly packed root segments. Do we know where I could find the script on Windows as it wasn’t obvious? Ta..
Damn windows search… located and will have a look later. Have a great day both! Cheers Keith
And promise not to press the submit button so many times next time… 🤨
Isn´t the path the same inside the Windows version?
...ish...
Hi both. Thanks for the input. Always learning... 😊
Which leads me to my next question.. I'm working on an extension (non turtle based) to draw roots and branches, something to get me into writing extensions and working with Python. Odd beast..
So I can generate multiple elements (with specified names / ids) onto a new layer group (with a specified name / id). The loop is "generate element", randomize some variables, generate a new element etc. What I would like to do is generate element, make it branchey / rooty, randomize variables, repeat. What I'm struggling with is how to select path / segment element (by id / by layer to get all?) and make it branchey / rooty. and whether I should generate all elements then do the fancy bit or do the fancy bit after the generation of each element. I'm guessing en masse at the end of the element generation stage would be more efficient.
I'm currently looking to have the py / inx files available via GitHub shortly, but not really used it much and just setting up VS code etc etc.. Have attached for now. Please excuse randomness, happy to accept advice. Happy to explain any of my non coder code if anyone has any thoughts!
Basically, the question is how do I select a path so I can use fractalise or some some pattern to make the elements more root / branch like. Thanks in advance.
UPDATE Aiming to keep this up to date, it would be great if you could confirm this works and is the standard method : https://github.com/ktacme/extensions.git
Cheers all
Topic moved to extensions forum.
If you are the creator of the elements, you can add an id as you create each one.
You can also add the id ( or the entire element to a list / dictionary etc )
If you do not assign an id, Inkscape will assign one automatically when the extension finishes running.
element.attrib['id'] = element_id
my_id_list.append(element_id)
If you want to select items after creation without using ids there are several options:
Please note it is not possible to pass back a 'selection' to the main Inkscape window
f
or element in group:
# output the id
inkex.errormsg(element.get_id())
# Output the element type
inkex.errormsg(element.TAG)
if you want to select elements by type, I usually use xpath
def get_drawable_elements(parent):
# Delete element types as you see fit.
elements = parent.xpath('//svg:circle | //svg:ellipse | //svg:image | //svg:line| //svg:path | //svg:polygon | '
'//svg:polyline | //svg:rect | //svg:text | //svg:textPath | //svg:title | '
'//svg:tspan | //svg:use')
return elements
groups etc into the function - https://www.w3schools.com/xml/xpath_syntax.asp
Thats just an example, xpath has a lot of options.
or you could loop through finding
element.TAG
of your choice etc.For creating the paths, I am not a mathematician
However unless you want to use fractals - there are many types of modified random walks - https://demonstrations.wolfram.com/ConstrainedRandomWalk/
I think that is how the original extension works. Python has a function, random.randrange(lower, upper) generally you would set upper and lower on a curve - fractions of 2 pi Radians.
Hi, thanks for your thoughts, appreciated! Not sure I quite understand, passing back a "selection" to the main Inkscape window but continual reading is leading me to come to the conclusion that Inkscape is "just" an XML (SVG) parser. "just" obviously" doesn't do it justice, but I think it's helping me understand how to manipulate elements.
Haven't touched XPath etc in quite some time, time to get back into it!
I'll check out some of the random walk algorithms and be sure to let you know how it goes! Have a great day all.
to correct an error the code I posted above should show
.//
instead of just//
https://www.w3schools.com/xml/xpath_syntax.asp
Hi all
Thanks for your input. Currently looking at the L-system extension as seems to do what I need! Have a great day all
Cheers Keith