• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

[JS] [Action] Split or break a dashed line into separate (real) lines by script

Community Expert ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

Illustrator does not offer a direct way to convert dashed lines (e.g. for cutting plotters or CNC engraving).

 

Please do not reply to suggest the way to set the outline thickness to a very small value e.g. 0.0001pt. This way still creates filled rectangles and not real lines and is therefore unsuitable.

 

I also know some existing scripts that try to redraw the dash line. Unfortunately, these scripts are not an option either, because the results sometimes differ from the originals.

 

For several years I have used the manual way to break up a dashed line into single (real) lines:
- select the dashed line
- (optionally) create a duplicate and turn off the visibility of the original
- draw a horizontal straight line (helper object)
- remove the dash line attribute from the straight line (helper object)
- create an artbrush from this line (option: Artbrush, no further options, usually just confirm twice)
- delete the line (helper object)
- assign the newly created brush to the original dashed line (or its duplicate)
- use the menu command Object --> Expand Appearance
- ungroup two times
- group the selection and name the group as desired
- delete the artbrush

 

Since this process is rare, but needs to be done over and over again, I wanted to create a script.

Unfortunately there is a problem. Adobe Extendscript cannot be used to create or delete a brush. But it is possible to create a brush with an action. This action can be included in a script. But this way always needs additional confirmations by the user:

- select the option: Artbrush
- confirmation of the selection with [OK]
- confirming the options dialog with [OK] (usually without further settings)

 

 

Question: Does anyone know a way to create an art brush via script or action without additional user interaction (and delete it afterwards)?

 

-------------------------------------------------------------------------------------------

For those interested, here is an example action to create a brush in text form:

 

/version 3
/name [ 16
	63726561746544756d6d794272757368
]
/isOpen 1
/actionCount 1
/action-1 {
	/name [ 16
		63726561746544756d6d794272757368
	]
	/keyIndex 0
	/colorIndex 0
	/isOpen 1
	/eventCount 1
	/event-1 {
		/useRulersIn1stQuadrant 0
		/internalName (ai_plugin_brush)
		/localizedName [ 6
			50696e73656c
		]
		/isOpen 1
		/isOn 1
		/hasDialog 0
		/parameterCount 1
		/parameter-1 {
			/key 1835363957
			/showInPalette -1
			/type (enumerated)
			/name [ 12
				4e657565722050696e73656c
			]
			/value 1
		}
	}
}

 

Many thanks in advance.

 

TOPICS
Draw and design , Scripting

Views

5.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Dec 24, 2021 Dec 24, 2021

Copy link to clipboard

Copied

One way is to use an additional helper document (helper_brush_001.ai) that contains just one object to which the helper brush (dashes_helper_001) is applied.

 

Given that you have opened just one document with a couple of dashed lines, you can take the following route.

 

dashed_lines_converter_action.png

 

Of course, depending on the contents of your files, the action will have to be modified.

 

Admittedly, a bit bumpy, but it works.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 24, 2021 Dec 24, 2021

Copy link to clipboard

Copied

Hello Kurt,

Thank you for your answer.

 

This variant would certainly be possible. However, I generally try to create actions or scripts as independent of additional files as possible. This way the scripts can be used on different computers and you don't have to worry about additional (necessary) files.

 

Maybe I also have to describe the initial situation a bit more detailed:
Basically, any artbrush (from a simple straight line) is suitable for conversion. But unfortunately another artbrush changes the properties of the stroke line. And in every delivered file there are differences. Although it would have no effect in the final file, there is a default that the attributes must remain the same. (The saved file is later matched with the original file).

While you could reassign the attributes in the script with a loop over each of the split small lines, any unnecessary loop is a performance killer. It's faster if you already assign the attributes to the straight line that serves as the base for the artbrush, as shown above.

 

Have a great holiday season to you and everyone else.

Translated with DeepL.com/Translator (free version)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 24, 2021 Dec 24, 2021

Copy link to clipboard

Copied

I think there are some good news, pixxxelschubser.

 

A flying reindeer just knocked at my window and told me that I should take a look at my actions archive. There should be something less bumpy. And indeed, I knew that I once made an action that converts dashed lines into separate stroked lines without using any helper objects.

 

You can download it here:

 

[Link to wrong files removed]

 

The .zip file contains a sample Illustrator file (dashed_lines_sample_001.ai) and an action set file (dashed_lines_nipper.aia).

 

- Open dashed_lines_sample_001.ai
- In the Actions palette import the action set file
- Select all objects
- Run the action

 

Give it a try.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 24, 2021 Dec 24, 2021

Copy link to clipboard

Copied

Oh, please ignore the nipper action, pixxxelschubser.

 

It does not work as it is supposed to work. I took the wrong files.

 

I'm pretty sure that I have an action that works. Will have a look next week.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 26, 2021 Dec 26, 2021

Copy link to clipboard

Copied

Bad news, pixxxelschubser.

 

I rummaged through my actions archive, but didn't find the action I thought I once created. Perhaps I have never created it or perhaps it is just lost in an unknown abyss.

 

Now, the good news.

 

This time the reindeer wasn't there, but instead a young raven knocked at my window yesterday and gave me a walnut. I cracked it and – lo and behold! – there was an action inside the nut.

 

"This action is not perfect", said the raven. "It usually may produce pretty clean results if you do not select too many dashed objects at the same time. Also, unlike the Art Brush route it usually does not produce tons of useless tiny chunk objects which have to be wiped away afterwards. And it preserves different stroke colours, in case that does matter here as well."

 

So far, I haven't checked if the entire story may be true or just flim-flam. However, you can download the approach here:

 

Dash Nipper

 

The .zip file contains a sample Illustrator file and an action set file.

 

- Open the sample Illustrator file
- In the Actions palette import the .aia file
- Select a dashed object and run the action

 

Let me know if this may be a suitable way for you.

 

Important note: Due to an Illustrator rounding error bug when writing the Preferences files, it may be that the action won't work after quitting and restarting Illustrator. In that case, unfortunately, you will have to delete the action set in the Actions palette and then reimport it. After that, it should work again.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 26, 2021 Dec 26, 2021

Copy link to clipboard

Copied

Hallo Kurt,

vielen Dank für deine Aktion.

 

Ich bin mir nicht sicher, ob ich sie einfach nur falsch anwende - oder ob sie so angelegt wurde. Aber leider werden weder in deiner Testdatei noch in meinen eigenen Testdateien "saubere" Striche (offene Pfade) erstellt. Meistens ergibt sich als Ergebnis eine Mischung aus offenen und geschlossenen Pfaden. Und das Aussehen der Strichlinien (z.B. Strichstärke) wird leider auch verändert.

 

Aber ich weiß ja aus meinen eigenen Versuchen, dass die ganze Problematik "nicht ganz ohne" ist. Deshalb trotzdem ein ganz liebes Dankeschön und noch frohe Feiertage.

 

Ach ja,

nachfolgend meine eigene kleine Skriptstudie zu diesem Thema. Funktioniert bei mir unter Windows mit den meisten Illustratorversionen. Ist noch im Teststadium und nicht ganz sauber geschrieben und daher nur als implementiertes Jsxbin. Ganz normal  z.B. unter pathItem_Stroke_dashed_line_remove_with_artbrush_jsxbin.jsx im Skripten-Ordner von Illustrator speichern, Illustrator neustarten, eine gestrichelte Linie erstellen und auswählen. Danach das Skript starten.

(Ich habe das Skript testhalber mit deiner Testdatei laufen lassen, aber da funktioniert die Umwandlung nicht reibungslos. Hier werden stellenweise zusätzliche Ankerpunkte erzeugt - das war bei meinen eigenen Dateien nicht der Fall.)

Hier das Testskript. Bitte nur mit Kopien und nicht mit ungespeicherten Originaldateien ausprobieren!

 

Ansonsten solltest du nach dem Testen einfach ab und zu deine Pinselpalette aufräumen. Zur Zeit kann immer nur eine Strichlinie nach der anderen umgewandelt werden. Bin mir noch nicht sicher, wie ich ein praxistaugliches Skript und meine eigenen Anforderungen kombinieren kann.

 

// pathItem_Stroke_dashed_line_remove_with_artbrush_jsxbin.jsx
// ---Testversion---
// braucht ein ausgewähltes gestricheltes Objekt - zerteilt eine gestrichelte Kontur in echte Einzellinien und 
// erhält die Eigenschaften (z.B. Strichstärke und Konturfarbe)
// pixxxelschubser 26. Dez. 2021

// ***************** Einstellung : Setting ********************
var show_hint_dialog = 1; // 0 switches off the dialog

// var always_create_duplicate = 1; // switch off not yet built in
// **************************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jBjMjVjFhAhRFeDJJjdFeCJjdFeBjdfRBFeBKff\
nftJkXnAEjzMjDjSjFjBjUjFiBjDjUjJjPjOhbfRBVhZfDffJkYnAEXzIjEjPiTjDjSjJjQjUhcfjWf\
RDVhTfAVhUfBFcfffJkZnAShZDnbffJkanAEXzMjVjOjMjPjBjEiBjDjUjJjPjOhdfjWfRCVhUfBFeA\
ffJkbnABXhWfjWfVhVfCnfAEhT40BiAhU4B0AiAhV4C0AiAhZ4D0AiAAEAhDAkcMkebyBn0AGJkfnAS\
zBjGheAEjzEiGjJjMjFhffRBFeWjehPjDjSjFjBjUjFiEjVjNjNjZiCjSjVjTjIhOjBjJjBftnftJlA\
nAEXzEjPjQjFjOiAfVhefARBFeBjXffJlBnAEXzFjXjSjJjUjFiBfVhefARBVzDjTjUjSiCfBffJlCn\
AEXzFjDjMjPjTjFiDfVhefAnfJlDnAEXzKjMjPjBjEiBjDjUjJjPjOiEfjWfRBVhefAffJlEnAEXhMf\
VhefAnfAChe40BiAiC40BhABBAhbAlFCJAnASLyBnegfiBjCjCjSjVjDjIhOhAiLjFjJjOhAjPjGjGj\
FjOjFjThAiEjPjLjVjNjFjOjUhOftOBbCn0ACJCnASGyBXzOjBjDjUjJjWjFiEjPjDjVjNjFjOjUiFf\
jWfnftJDnAEjhSfnfACzBheiGXIfXzJjEjPjDjVjNjFjOjUjTiHfjWfnndAbyFn0ABJFnAEjMfRBVLf\
yBffACL40BiAG4B0AiAACAEByB""");

 

Falls jemand eine Möglichkeit findet, die für die Pinselerstellung notwendigen Dialogfelder zu unterdrücken, dann bin ich weiterhin für jeden Ratschlag offen.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

Hallo pixxelschubser,

 

wie findest Du die Zerstückelungsquote mit dieser Spielart?

 

Dash Nipper 2

 

Ein Beispieldokument zum Testen ist wieder enthalten.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

Hallo Kurt,

danke vielmals für dein Interesse an der „Problematik“ und dem Versuch einer Lösungsfindung. Aber scheinbar verändert der Weg über eine reine Aktion immer die Strichlängen und er erzeugt auch oft geschlossene Pfade. Davon abgesehen verändert er auch die anderen Eigenschaften der Kontur (im Screenshot: original = schwarz | Resultat der Aktion = rot). Das macht eine Gegenprüfung mit dem Original leider fast unmöglich.

aa15.png

 

 

Wahrscheinlich werde ich versuchen, meinen Skriptansatz noch etwas zu verfeinern und mit den „lästigen“, aber leider notwendigen Klicks für die Pinselerstellung zu leben. So könnte ich am Anfang die nicht benötigten Pinsel löschen – und nach der Umwandlung den gleichen Schritt noch einmal anwenden. Dadurch bleibt auch bei mehreren umzuwandelnden Strichlinien die Pinselpalette „sauber“. Dann könnte man das Skript entweder über eine Aktion starten und auf diesem Weg mit einem Tastenkürzel versehen – oder über meine eigene Skriptpalette einbauen. So spart man sich auch noch die „unnötigen“ Klicks für den Skriptaufruf über das Menü.

 

Und man soll ja die Hoffnung nicht aufgeben. Vielleicht bauen die Adobe-Entwickler in Zukunft ein paar zusätzliche Anbindungen in ihre Extendscript-Schnittstelle ein. Oder ein anderer Scripter wie z.B. @CarlosCanto, @Silly-V, @m1b, @Disposition_Dev, @Charu Rajput, @brian_p_dts oder auch unsere „Newcomer“ @femkeblanco und @Parts4Arts hat/ haben noch eine geniale zündende Idee.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

Hi @pixxxelschubser, I'm interested in this problem too and I'm trying a scripting approach. We'll see if I get anywhere, but so far it's looking promising.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2022 Jan 19, 2022

Copy link to clipboard

Copied

Just letting you know that I am still working on this problem whenever I get time and have so far made great progress, after many failed experiments. Will have something to post in the next week or so I hope.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

you must be desperate to summon the heavy guns 🙂

 

quote

Oder ein anderer Scripter wie z.B. @CarlosCanto, @Silly-V, @m1b, @Disposition_Dev, @Charu Rajput, @brian_p_dts oder auch unsere „Newcomer“ @femkeblanco und @Parts4Arts hat/ haben noch eine geniale zündende Idee.

 

By @pixxxelschubser

 

bringeveryone.gif

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

OK, pixxxelschubser.

 

Du solltest allerdings vielleicht mal ein paar echte Beispieldateien (Ausgangsdateien) zur Verfügung stellen.

 

In meinen Testdokumenten habe ich heute Auswahlen von gestrichelten Objekten mit der Aktion (Dash Nipper 2) bearbeitet, die bis zu 10.000 einzelne Pfade erzeugt haben. Davon waren nur ein paar wenige geschlossen. 99,9 Prozent waren offene Pfade mit jeweils 2 (selten 3 oder mehr) Ankerpunkten. Also eigentlich genau das gewünschte Ergebnis. Es trifft zu, dass unterschiedliche Strichstärken nicht erhalten bleiben. Das kann die Aktion nicht.

 

Wieviele geschlossene (unerwünschte) Pfade hast Du in meinem letzten Beispieldokument erhalten, nachdem die Aktion ausgeführt wurde?

 

Eine kleine Verfeinerung der Aktion werde ich morgen bereitstellen.

 

Apropos: Wie gehst Du zurzeit mit den Unmengen an überflüssigen Objekten um, die die Methode mit dem Bildpinsel erzeugt? Das dürfte doch Gift für die CNC-Steuerung sein.

 

-------------

 

In English:

 

OK, pixxxelschubser.

 

You may want to provide a couple of real sample files, so one may have a closer look at them.

 

Today I took some sample files and applied the action (Dash Nipper 2) to a selection of dashed objects that finally produced up to 10.000 separate paths. Just a few of them were closed. 99.9 percent were open paths, each with 2 anchor points (rarely 3 or more points). As far as I can see, that is the desired result. It is true that stroke weights are not preserved. The action cannot do that at the moment.

 

How many unwanted closed paths did you get when applying the action in the sample file I provided in my previous post?

 

I will provide a slightly modified version of the action tomorrow.

 

By the way: How do you currently handle the vast amount of useless objects that are created when using the Art Brush method? That is probably pretty harmful for any kind of CNC-processing.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

Hi pixxxel, you have very specific demands that are hard to meet

 

- no suggesting to apply small strokes

- no redrawing the small paths

- no helper files (independent scripts only)

- no performance killer loops

 

you're killing us!! hahaha

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

I was curious on the lack of scripting support because in Types-for-Adobe typescript OMV-based type definitions there is a document.brushes.add(file, name) and document.brushes.addAndLoad(file) methods.

But of course none of these work at all.. or is that completely true?

The error message is not that this method is not a function but rather the funny Illustrator error "CAN'T".

Also, it does work up to some point because if you do not put the right kind of argument, such as the File object into the 1st argument spot, it will complain that the argument it needs is supposed to be a File.

Could there be a file format that does work? I doubt it, I tried .ai compressed and uncompressed, with PDF and without PDF content and it didn't work.

For this case if dynamic brushes could be created and their names could be controlled, then maybe the script could have made its own temp helper documents and removed them after use.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

hmm...interesting, perhaps those are ancient methods that are no longer supported?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

Hi @CarlosCanto 

Desperate? No.

I have a working solution approach. You can try my own test script from my post https://community.adobe.com/t5/illustrator-discussions/js-action-split-or-break-a-dashed-line-into-s...

But maybe with the collective swarm knowledge we can find a better solution for something Illustrator doesn't offer - but finds too few advocates to become a successful feature request. Simple and easy to handle.

 

Do you know: "Obstacles and difficulties are steps on which we climb up to the heights." (Friedrich Nietzsche)

😉

 

By the way: I love the Movie "Leon the Professional"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

quote

By the way: I love the Movie "Leon the Professional"


By @pixxxelschubser

 

It's one of my favorites, love it as well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

@Kurt Gold 

An "echte" Daten komme ich erst wieder nach dem Jahreswechsel. Aber ich kann sicherlich etwas basteln. Es geht tatsächlich ausschließlich um in Illustrator erstellte gestrichelte Konturen auf geraden und auch auf gebogenen Pfaden.

 

Mit geraden Strichlinien funktioniert deine Aktion. Geschlossene Pfade treten meiner Meinung nach nur bei elliptischen, runden oder sonstigen gebogenen Pfaden auf. Ich habe in deiner Datei nur mit den Eigenschaften des untersten Pfades eine Ellipse mit ca. 47 x 22mm erstellt und dann die Konturstärke auf 2 mm erhöht und den Abschluss auf abgeflacht gestellt. Der Screenshot weiter oben zeigt die Anzahl der entstandenen offenen und geschlossenen Pfade.

 

Was mich selbst extrem verwundert hat: deine Dateien waren die allerersten, in denen überhaupt solche überflüssigen Objekte entstanden sind. Ich habe so etwas zuvor noch nie erlebt. Es ist aber (fast) egal. Unsere CNC-Programme haben sehr gute Importfilter. Viele der überflüssigen einzelnen Ankerpunkte werden beim Einfügen der Dateien automatisch bereinigt und es ist relativ einfach weitere gezielte Säuberungen durchzuführen.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

Gut, vielen Dank, pixxxelschubser.

 

Ich bin gespannt auf Deine Beispieldateien und werde natürlich testen, ob die Bildpinsel-Methode dort keine "chunk objects" erzeugt. Glaube nicht daran, aber wer weiß ...

 

Morgen gibt's noch eine neue Aktion inkl. Beispieldokument mit allen möglichen offenen und geschlossenen Strichelobjekten.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

pixxxelschubser_0-1640654622339.png

 

… Ich … werde natürlich testen, ob die Bildpinsel-Methode dort keine "chunk objects" erzeugt. Glaube nicht daran, aber wer weiß ...

 

By @Kurt Gold

 

Nur noch zwei kleine Zwischenfragen:

  • Mac oder PC? (den Zip-Dateien nach wahrscheinlich Mac)
  • "deine eigene manuelle" Bildpinsel-Methode oder mein Test-Skript?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

- Mac oder PC: Beides vorhanden und es wird immer auf beiden getestet.

 

- Natürlich beide Bildpinsel-Methoden. Zusätzlich die vom Raben. Das kommt ja alles nur von ihm.

 

Gute Nacht

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 27, 2021 Dec 27, 2021

Copy link to clipboard

Copied

Hi pixxxel, on Windows we can use a jsx mixed with vbs to send clicks to Illustrator to dismiss the Brush Windows.

 

how to set up this excercise

 

- create a "createBrush" Action in a "test" Action Set

- select a path to create an Art brush from

 

- save this vbs script anywhere (your jsx could create and execute this vbs on the fly)

 

'Option Explicit

Dim Shell, WMI, wql, process, processes

Set Shell = CreateObject("WScript.Shell")
Set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

wql = "SELECT ProcessId FROM Win32_Process WHERE Name = 'illustrator.exe'"

For Each process In WMI.ExecQuery(wql)
  Shell.AppActivate process.ProcessId

  Wscript.Sleep 3000
  Shell.SendKeys "{TAB}{TAB}"
  Wscript.Sleep 500
  Shell.SendKeys "%A" 
  Wscript.Sleep 500
  Shell.SendKeys "{ENTER}"
  Wscript.Sleep 500
  Shell.SendKeys "carlosBrush{ENTER}"

  exit for
  msgbox "after exit for" 'this never executes
Next

'msgbox "done"	

 

 

finally run the following jsx, adjust the path to point to your own vbs file

 

// creates an Art Brush via Action (with Dialogs), vbs will choose Art Brush and dismiss dialogs

var vbs = File("C:/Users/canto/Google Drive/Adobe Scripts/addBrush_sendKeys_test.vbs");
vbs.execute();
        
app.doScript("createBrush", "test");

 

 

have fun!

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 28, 2021 Dec 28, 2021

Copy link to clipboard

Copied

pixxxelschubser,

 

now I know the reason why you got (many) closed objects with curved dashed strokes. There is yet another Illustrator bug in the Actions palette. That is, the very first action step (adjusting the Pathfinder settings) is being ignored if the modal dialog for this step is turned off.

 

Unfortunately, one has to turn it on and then has to hit the Enter key one time while the action is running. Alternatively, you can manually adjust the Pathfinder settings once per Illustrator session and then turn the modal dialog off in the Actions palette.

 

Here you can download the modified and slightly improved action.

 

Dash Nipper 3

 

It also contains a sample Illustrator file with all kinds of dashed paths (artboard 1). On artboard 2 you can see the results I got after running the action.

 

As already mentioned in a previous post, due to an Illustrator rounding error bug when writing the Preferences files, it may be that the action won't work after quitting and restarting Illustrator. In that case, unfortunately, you will have to delete the action set in the Actions palette and then reimport it. After that, it should work again.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2022 Jan 23, 2022

Copy link to clipboard

Copied

Hello pixxxelschubser,

 

I'll offer a solution other than art brushes: you can use Live Paint as a pathfinder for strokes.

/**
  * @File expand a dashed stroke  
  * https://community.adobe.com/t5/illustrator-discussions/js-action-split-or-break-a-dashed-line-into-separate-real-lines-by-script/td-p/12614309
  * @version 1.0.0
  * @author sttk3.com
  * @copyright © 2022 sttk3.com
*/

//@target 'illustrator'

(function() {
  if(app.documents.length <= 0) {return ;}
  var doc = app.documents[0] ;

  // only one selection is allowed
  var sel = doc.selection ;
  var messageInvalidSelection = 'Select one dashed stroke and execute this script.' ;
  if(sel.length != 1) {
    alert(messageInvalidSelection) ;
    return ;
  }
  
  // terminate when selected item is not a path, not a dashed stroke, or has a fill
  var originalPath = sel[0] ;
  if(!/^PathItem$/.test(originalPath.constructor.name)) {
    alert(messageInvalidSelection) ;
    return ;
  }
  if(originalPath.strokeDashes.length <= 0) {
    alert(messageInvalidSelection) ;
    return ;
  }
  if(originalPath.filled) {
    alert('This script should be execute after the fill is removed.') ;
    return ;
  }

  // generate a unique color
  var tempSpot = doc.spots.add() ;
  var tempColor = new SpotColor() ;
  tempColor.spot = tempSpot ;
  tempColor.tint = 100 ;

  try {
    var pathfinderGroup = originalPath.layer.groupItems.add() ;
    pathfinderGroup.move(originalPath, ElementPlacement.PLACEBEFORE) ;
    var maskWidth = originalPath.strokeWidth + 1 ;

    // object to fill dash
    var dashPath = originalPath.duplicate(pathfinderGroup, ElementPlacement.PLACEATEND) ;
    dashPath.strokeWidth = maskWidth ;

    // object to fill gap
    var gapPath = originalPath.duplicate(pathfinderGroup, ElementPlacement.PLACEATEND) ;
    gapPath.strokeWidth = maskWidth ;
    gapPath.strokeDashes = [] ;
    gapPath.strokeColor = tempColor ;

    // leave fill only at gaps
    doc.selection = [pathfinderGroup] ;
    app.executeMenuCommand('OffsetPath v22') ; // Outline Stroke
    app.executeMenuCommand('Live Pathfinder Subtract') ;
    app.executeMenuCommand('expandStyle') ; // Expand Appearance
    app.executeMenuCommand('compoundPath') ; // Compound Path Make
    
    // remove gaps of originalPath by live paint
    originalPath.strokeDashes = [] ;
    originalPath.selected = true ;
    app.executeMenuCommand('Make Planet X') ; //  Live Paint Make
    app.executeMenuCommand('Expand Planet X') ; //  Live Paint Expand
    app.executeMenuCommand('ungroup') ;
    app.redraw() ;
    
    // remove gapPath
    var tempGroups = doc.selection ;
    var itemColor ;
    for(var i = tempGroups.length - 1 ; i >= 0 ; i--) {
      itemColor = tempGroups[i].pathItems[0].fillColor ;
      if((itemColor.constructor.name == 'SpotColor') && (itemColor.spot == tempSpot)) {
        tempGroups[i].remove() ;
        break ;
      }
    }
  } catch(e) {
    alert(e) ;
  } finally {
    tempSpot.remove() ;
  }
})() ;

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines