What's new

Release: Import SVG Dialog

NateLiquidGravity

Alibre Super User
Import SVG Dialog
by NateLiqGrav
2/13/2022
Import SVG files to a new Sketch on a Plane using the new ImportSVG function found in Alibre Script in Alibre Design V24 with a convenient dialog for the user to select the file and the plane.

If the SVG does not import correctly try opening and saving in a different SVG editor and then importing that result.
I had decent results with the following website: https://www.freecodeformat.com/svg-editor.php
 

Attachments

  • Import SVG Dialog.py
    1.6 KB · Views: 70
Last edited:
Thank you so much! This should be included in Alibre by default. Not even a need to mess around with the drawing workspace.

I found one small bug but was able to fix it, some curves import some distance away from the base part. This happens with both the original and the one converted through the site.

Screenshot 2022-02-13 163154.jpg

I just used the move tool to reposition the outline

Screenshot 2022-02-13 163658.jpg

And it extrudes perfectly right on import!

Screenshot 2022-02-13 163802.jpg
 
And where exactly it this new Import found in AD v24? :confused: :confused:
It's not official, it's a script NateLiqGrav made that uses the API to import an SVG. It looks like the functionality is part of Alibre but there's no built in import dialogue. Download the script and save it in "C:\Users\[USER]\OneDrive\Documents\Alibre Script Library". At least that's where mine live.

Go to the Script tab in Alibre Pro or Expert and click launch, then select the script and press run. Don't close the console tab or it won't launch at all.

Screenshot 2022-02-13 204017.jpg

It worked for me first try, I just had to move one outline which decided to float off to the side for some unknown reason. Select all points in sketch mode and use the move tool.
 

HaroldL

Alibre Super User
Import SVG files to a new Sketch on a Plane using the new ImportSVG found in Alibre Design V24 with a convenient dialog for the user to select the file and the plane.
He didn't say anything about a script, if you read the post it infers that it is a new function found in v24. Other than the post title that states something about a Release of the import dialog it still sounds like v24 has a new import function. Just a bit confusing since in the File menu or ribbon there is no Import option.
 

simonb65

Alibre Super User
He didn't say anything about a script
He attached the script to the bottom of the first post! ImportSVG is an internal function of the API and scripting language as used by Nate's script ... which he included in the post! ... and the post is in the AlibreScript forum topic. So, to me, that inferred this was a script.
 

NateLiquidGravity

Alibre Super User
For clarity I have edited the original post to indicate the new ImportSVG function is found in Alibre Script in Alibre Design V24.
 

Cator

Senior Member
Nate is it also possible to export a svg ?? I tried EsportSVG but I can't activate it .... your help would help me a lot, thank you if you can help me!
 

idslk

Alibre Super User
Python:
# '***  Export SVG Dialog                                     ***'
# '***  by IDSLK              05/03/2022                      ***'
# '***  Export a sketch to a new SVG file                     ***'
# '**************************************************************'
Win = Windows()

ScriptName = "Exports a sketch as a SVG-file"

prt = CurrentPart()

Options = []
Options.append(['Choose an Sketch', WindowsInputTypes.Sketch, None])
Options.append(['Directory', WindowsInputTypes.Folder, None])
Options.append(['Name (.svg will be added automatically)', WindowsInputTypes.String, 'SVG_Probe'])
Values = Win.OptionsDialog(ScriptName, Options, 300)
print Values
if Values == None:
    sys.exit('user canceled')

if Values[0] == '' or Values[0] == None:
    print('No Sketch Selected')
    sys.exit()

if Values[1] == '' or Values[1] == None:
    print('No Directory Selected')
    sys.exit()

if Values[2] == '' or Values[2] == None:
    print('No Filename given')
    sys.exit()

SVGFile = Values[1]+"\\"+Values[2]+".svg"
sk = Values[0]
sk.ExportSVG(SVGFile)
print('Done.')

uses the AlibreScript function "ExportSVG"

May you try it...I don't know how good the exporter works...

Regards
Stefan
 

Cator

Senior Member
Thanks Stefan, unfortunately the export does not produce anything that can be used .... too bad ......
 

idslk

Alibre Super User
unfortunately the export does not produce anything that can be used
I've checked this and found that here on my installation (German) that the "everytime fail" has occured: The export uses an colon insteat of a point...(Decimal and Thousands Separators)
"Quick fix": opening the exported file in a text editor and running an exchange "," to "." and saving the file again has made the export usable for me... :)
Maybe the "Error" does not occur in "english" installations.

Regards
Stefan
 

Cator

Senior Member
Ho,
is it possible to choose a shortcut for this new function in addition to the choice from the context menu?
 
I could have just used this script! Here was my workaround: Used an online involuted gear generator but neither .dxf nor .svg imported without too many errors to extrude or manually fix. So I imported .svg into Inkscape.. File>Clean up document. Then save as (autocad dxfR12) .dxf It works perfectly every time.
 
Very cool, but I don't deserve such praise for this simple dialog to wrap an existing function.
It may be a simple import dialogue script, but I never would have known about the function otherwise :p

I use SVG import a lot, before Alibre it was in blender. Boolean cleanup was always a horror show, Alibre/NURBS are cleaner. Good practice too, trying to use Alibre as much as possible when designing models for print.
 
Top