haraldw93098100
New Here
haraldw93098100
New Here
Activity
‎Sep 02, 2024
07:40 AM
Hello @CarlosCanto I think the problem is not duplicating the groups. I changed my code. I have same problems copying the PageItems: for (int i = 1; i <= source.PageItems.Count; i++) {
source.PageItems[i].Duplicate(newLayer); } It doesn't run into any errors here, but the AI ​​file seems to be corrupt after this operation. That's why the "replaceDecimalSeparator.js" runs into an error 45 later.
... View more
‎Aug 29, 2024
01:02 AM
Hello @CarlosCanto I have done some more tests. After running the Duplicate() function, the AI ​​file is in an unstable state. The elements are not always correctly transferred to the new layer. This is why error 45 sometimes occurs when accessing the elements later. The Duplicate() function still worked in the old version of Illustrator 2015. Now the function only works with a probability of around 50%. It seems that access via COM automation is not stable.
... View more
‎Aug 27, 2024
01:59 AM
Thank you very much for your help! Yes, the file "replaceDecimalSeparator.js" runs without errors. The problem is the Duplicate() function. I think that's too many operations for COM automation. In this loop, about 150 elements are copied into the new layer: for (int i = 1; i <= source.GroupItems.Count; i++) {
source.GroupItems[i].Duplicate(newLayer);} It doesn't run into any errors here, but the AI ​​file seems to be corrupt after this operation. That's why the "replaceDecimalSeparator.js" runs into an error 45 later. If I don't run the Duplicate() function, the program runs without errors. So I think the problem is in the Duplicate() function. How can I code the copying of a layer differently with COM? Or I can replace it with a JavaScript function. Is there a code snippet in JavaScript for copying a layer?
... View more
‎Aug 22, 2024
08:10 AM
We have created a small C# project on Github (Program.cs). The script and AI file are also included. https://github.com/danielnierlin/IllustratorScriptExample It was noticeable that if I just open the AI file ​​and run the script on the original layer "MD_2_BEMASSUNG", it always worked. The problem only occurs if I duplicate the layer first. We do this via COM with Duplicate(). Thank you very much for your help!
... View more
‎Aug 21, 2024
07:23 AM
I have done further tests. Error 45 occurred in about 50% of all tests. In all other cases the script ran without errors. Why does the script not run stably in Illustrator version 2024? This bug was not present in the older Illustrator version 2015. What kind of bug is this in Illustrator 2024? Sometimes the query goes to the groups, sometimes an error is thrown. Only try-catch helps. And I have tried this in various ways. Repeatedly with waiting times and with app.redraw(). Unfortunately, that didn't improve things either. What can help to fix error 45 (object is invalid)? Does anyone have an idea?
... View more
‎Aug 20, 2024
07:00 AM
We have a .NET application which calls a Javascript function via COM in Adobe Illustrator 2024 V28.6. Sometimes it works, but sometimes we get an error. Everything worked in the old Adobe Illustrator 2015. Sometimes we get this error: Object is invalid -> getTextFrames(group.textFrames, textFrames); See last lines in the JS code below. The group object is invalid! The script errors only occur when the script is called programmatically. When the script is called via the Illustrator interface or via the ExtentedScript Toolkit, the scripts run without any problems. var defaultNumberDecimalSeperator = "##defaultNumberDecimalSeperator##";
var newSeparator = "##newSeparator##";
var layerName = "##layerName##";
var doc = app.activeDocument;
var myLayer = doc.layers.getByName(layerName);
replaceDecimalSeparator(myLayer, newSeparator)
function replaceDecimalSeparator(layer, newSeparator) {
var textFrames = getAllTextFrames(layer);
for (var i = 0; i < textFrames.length; i++) {
var myTextFrame = textFrames[i];
var myContent = myTextFrame.contents;
var index;
// Alle Dezimaltrenner im Textrahmen ersetzen
do {
index = myContent.indexOf(defaultNumberDecimalSeperator);
if (index === -1) {
break;
}
myTextFrame.characters[index].contents = newSeparator;
myContent = myTextFrame.contents; // Inhalt nach der Änderung neu laden
} while (index !== -1);
}
}
// Rekursive Funktion zum Ermitteln aller TextFrames in der Ebene
function getAllTextFrames(myLayer) {
var myTextFrames = [];
getTextFrames(myLayer.textFrames, myTextFrames);
getTextFramesInGroups(myLayer.groupItems, myTextFrames);
return myTextFrames;
}
function getTextFrames(frames, myTextFrames) {
for (var i = 0; i < frames.length; i++) {
myTextFrames.push(frames[i]);
}
}
function getTextFramesInGroups(groups, mytextFrames) {
var myGroup;
for (var i = 0; i < groups.length; i++) {
myGroup = groups[i];
getTextFrames(myGroup.textFrames, mytextFrames);
getTextFramesInGroups(myGroup.groupItems, mytextFrames);
}
} We tested with sleep() and app.redraw. Unfortunately without success. Best regards Harald
... View more
‎Mar 16, 2018
09:18 AM
Any News (2 years later) about this function "Adjust dashes" in Illustrator. Where can I ask Adobe for implementing this function for Scripting?
... View more
‎Mar 10, 2018
01:39 AM
I have done several tests. The center lines are correct when I use the internal Illustrator stroke buttons: When I did this steps manually: - Open DWG file - Use the stroke menu to align the dashes (not Javascript function) - Export to SVG Then the center lines in the SVG file are correct. It seems, the Javascript function is not working correctly. What can I do?
... View more
‎Mar 08, 2018
08:53 AM
The drawing is a DWG file. My Illustrator script did: - Open DWG file - Align the center lines with the Javascript function I mentioned above Because I cannot use the internal Illlustrator function in the Stroke menu - Export to SVG
... View more
‎Mar 08, 2018
06:13 AM
The coordinatePrecison=7 gives also wrong result. I have no experience with graphic styles for center lines. When I use Object->Path->Outline stroke before SVG export it works! But I am not sure, if there are other negative effects? I have done a lot of tests now! It looks like a scaling problem, because the SVG Export works, when I open my DWG file with scaling=5 instead scaling=1.
... View more
‎Mar 07, 2018
09:28 AM
Hello, it is not possible to use this function in the Stroke menu in Illustrator 2015 via Scripting: This is the reason, why I use this Javascript function: s.h's page : Scripts for Adobe Illustrator CS Now I have a Problem, when I export a drawing in SVG format. I have today a discussion in the Illustrator forum: Export SVG changed the dashed line The end of the discussion was, that the SVG export works, when I use the internal Illustrator function. Unfortunately the SVG export does not work with the Javascript function. I use the Javascript function in Illustrator. And the drawing looks fine in Illustrator: But when I export the drawing in SVG Format, then center line is wrong: When I adjust the dashes with the internal Illustrator function, then the SVG export looks fine. Note: The drawing is imported in Illustrator from DWG format. What can I do? Can I use the internal Illustrator function in the newest Version via Scripting? Is there an update of the Javascript function? Any other workaround possible? Best regards Harald
... View more
‎Mar 07, 2018
07:04 AM
I have done a lot of tests. The SVG Export works, when I use the adjusting of Illustrator with these buttons in the Stroke menu: When I use the Javascript function then it does not work. But I cannot use the Illustrator function, because it is not scriptable. What is the solution?
... View more
‎Mar 07, 2018
04:35 AM
I use exactly this script to adjust the dashes.
... View more
‎Mar 07, 2018
04:11 AM
OK, so what can be the solution? Can I convert the dashes to "normal" lines (Object->Expand)?
... View more
‎Mar 07, 2018
04:00 AM
Thank you for this quick response. That means, the SVG Export is not using the alignment of the Illustrator?
... View more
‎Mar 07, 2018
01:49 AM
Hello, I am using Illustrator CC 2015.1.0. I have dashed lines in my drawing for center line. I have a script to align dashes to corners and path ends. This works fine. Then I have my drawing in Illustrator: I have to export the drawing in several formats, like png, jpg and svg. The export to png and jpg is correct. But the export to svg is wrong. The dashed line in the center is not correct. Look here: It seems, that the SVG Export adjust the dashes. What can I do? Best regards Harald
... View more