Copy link to clipboard
Copied
Hello,
I'm new to Illustrator scripting, trying to do this in JavaScript.
I'd like to retrieve the "width" property for each anchor point in a path.
When I use the Width Tool, I can change the width for each anchor point along a path. That's easy. Now what I'd like to do is (in a script) loop through each point in a path shape, retrieve the XY coords for the point, but in addition- retrieve the stroke width for each anchor point.
I am assuming this is possible, because when I hover the Width Tool over an anchor point, I get a pop-up that shows me- very clearly, what the stroke width is at that point. It shows Side 1, Side 2, and Width.
Ultimately I am trying to export a text file. The text file format would be something like this:
Path_01 : X , Y , width
pt_1 : 118 , -116 , 1
pt_2 : 664 , -377 , 36
pt_3 : 528 , -585 , 1
Should be simple, and any help greatly appreciated!
Thanks
Copy link to clipboard
Copied
I would love to access to the variable With Tool via javascript.
alas, I have not found any way to do so.
I don't think it is possible.
the tool has been available since CS5.
That's 5 full versions ago and we still have no access.
please adobe, can we please have access to script the width tool, please...
How about now...
now...
what about now?
(more time passing......)
maybe now? ![]()
Copy link to clipboard
Copied
one way that may make it possible to HACK some scriptability into the width tool is to look at stroke profiles.
there is a file called "VariableWidthProfiles" that contains all the info for the saved stroke profiles.
I have edited this manually and had success.
it may be possible to create your variable width path.
then save it as a profile.
then read the "VariableWidthProfiles" file from your userprofile to get the hex data,
convert the hex to ascii, and then convert all that data to your widths etc..
would be quite a task.
but possible...
Thinking out loud...
this is Width Profile 1
this is the excerpt from the "VariableWidthProfiles" file:
/collection1 {
/attributes {
/VariableWidth_ProfileType 0
/VariableWidth_Distances [ 22
3020302e353031353939393637343739373036203120
]
/VariableWidth_Widths [ 6
302031203020
]
/collectionName [ 15
57696474682050726f66696c652031
]
}
/canEdit 0
/canDelete 0
}
distances has 22 hex pairs.
converts to:
0 0.501599967479706 1
(0 = start , 1 = end) so the 0.5... is the middle.
widths has 6 hex pairs
converts to:
0 1 0
(0 = start width is 0% of stroke width , 1 = middle is 100% of stroke width , 0 = end width is 0% of stroke width)
not sure if this helps any but may help someone somewhere sometime... maybe...
Copy link to clipboard
Copied
Thanks very much for this in depth answer. I wish there was (duh) an easier way to do this!
The main problem with the method you described (which is awesome by the way) is that in my workflow, I'd have hundreds of paths in a single document. Each path would have an entirely different variable width stroke.
Each would have to be it's own profile. This means I'd have to create the art, save each path as a profile, scour through each profile, extract ... yikes.
I dug around a bit more, looking for a way to automatically copy the popup context menu. Let me explain- if you have a path with say 10 points, each point has a variable stroke width. If you select the Width Tool, go to a point, and double click it, there is a popup menu. The header is "Width Point Edit". The values I need to extract are right there! It seems possible to select the "Total Width" value field, copy it to the clipboard, paste it into a text file, go to the next point.... I'm playing around with that theory for awhile before I cry and give up ![]()
Anyone think this is crazy or possible? Is it likely that in order to do this I'd have to give up on scripting and write a plugin with the SDK?
Thanks again for your answer!!!!
Copy link to clipboard
Copied
‌my answer was never going to be a real solution.
ARe you on a PC?
wounder if ahk may be able to help.
ill take a look soon and let you know if I have any success
Copy link to clipboard
Copied
when you double click the anchor to get the width properties, that window has values that AHK can access.
this would still be a very slow process though.
have you used AHK before? does only run on a PC...
Copy link to clipboard
Copied
...another non-real solution...expand appearance and painfully get the anchor pairs.
Copy link to clipboard
Copied
I got excited when you said that but the points don't correspond with the anchors added with the width tool.
but if you add a gradient to the stroke then expand appearance creates a mesh. this at least has a fairly even distribution of points along the length.
Copy link to clipboard
Copied
qwertyfly- I am on a pc and I took a look at the Auto Hot Key possibility... I'm thinking it could work only if combined it with a script that could initiate a double click....
Wow, something i thought would be pretty easy turned out to be very hard.
I'm trying to do this because (long story) the stroke widths can translate to line weights on a drawing robot. Using a (real) brush pen attached to a drawing robot, the robot draws the line using the x,y pairs, but if you can throw in the stroke width for each point you can make nice weighted lines as well, instead of a single weight. Beautiful robot calligraphy. But in order to do this, you need to draw some lines in a cool drawing program (like Illustrator) that has a variable stroke width tool (like Illustrator) and then export the stroke width for each point (not Illustrator) ![]()
Any Adobe folks wanna help out on this?
Copy link to clipboard
Copied
AHK could do the dblClick for you.
So is this a physical Robot. this project sounds very cool.
I must see photos...
is the idea that you draw something in Illustrator then export data to the robot and then watch it recreate your drawing in the Real world on Real paper?
I really like the sound of this.
did I say I want photos?
I want video!!!
I would love to know more about this project.
are you using something like "MACH3" in some kind of CNC fasion to send it its path and depth along the way to achieve the pressure of the stroke?
if that is the case you may be able to expand appearance to get the shapes then feed that into some CAM software with V cut capability to create the "cut paths"
I now want to explore this idea for my CNC machine I built.
send me more info on the steps from drawing to robot and I see if I can nut out a way to achieve this.
email me if you don't want it all posted publicly.
Copy link to clipboard
Copied
hey!! we all want to see drawing robots ![]()
Copy link to clipboard
Copied
I Was not talking about photos.
post those here.
‌
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more