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

Place SVG via script

Explorer ,
Apr 03, 2025 Apr 03, 2025

I have a script I have used to place Illustrator art inside of other open documents. It places them at the coordinates in the code. I have come up with the need to place dynamically created SVG files into Illustrator documents. When I try to use the script for placing SVG, it does not work (gives a bunch of errors). I can manually place the SVG file into Illustrator. However, I cannot have the position predetermined as the script can do. When I place the SVG, it is only the art, not any artboard or bounding area like the Illustrator (.ai) file. This works well for my application now. If there is any way to do it, I would like to find out. Thanks

 

var doc = app.activeDocument;

// Replace this with your actual file path 
var filePath = new File("C:/Test/data1990.svg"); 

if (filePath.exists) {
    var placedItem = doc.placedItems.add();
    placedItem.file = filePath;  // Assign file to placed item
    placedItem.position = [100, 200]; // X = 100, Y = 200 (Adjust as needed)
} else {
    alert("Error: File not found! Check the file path.");
}

 

 

TOPICS
How-to , Import and export , Scripting
296
Translate
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

correct answers 1 Correct answer

Advocate , Apr 04, 2025 Apr 04, 2025

Il faut utiliser

var placedItem = doc.groupItems.createFromFile( filePath );
Translate
Adobe
Advocate ,
Apr 04, 2025 Apr 04, 2025

Il faut utiliser

var placedItem = doc.groupItems.createFromFile( filePath );
Translate
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
Explorer ,
Apr 07, 2025 Apr 07, 2025
LATEST

Merci beaucoup, c'était super utile 😊

Translate
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