How can I set the .stil import unit system (Spaceclaim/Discovery)

Mike.Thompson
Mike.Thompson Member, Employee Posts: 391
100 Likes 25 Answers 100 Comments Second Anniversary
✭✭✭✭
edited August 2023 in 3D Design

How can I use the document insert API to insert an stl but specify the unit system to use for that file?

Options = ImportOptions.Create()
Options.Stl.Units=??

Best Answers

  • Adriano Zaffora
    Adriano Zaffora Member, Employee Posts: 23
    Second Anniversary 5 Answers 10 Comments 5 Likes
    ✭✭✭✭
    Answer ✓

    According to the API documentation,
    StlImportOptions.Units Property
    should provide support to STL unit change.
    Please, check the documentation for full information on this property (commonly it is found in your local installation e.g. "C:\Program Files\ANSYS Inc\v242\scdm\SpaceClaim.Api.V242\API_Combined_Class_Library.chm" )

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 327
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    Answer ✓

    Below is small example that does this:

    file='D:\deformed.stl'
    
    from SpaceClaim.Api.V232 import *
    
    
    #a=MetricUnits(MetricLengthUnit.Millimeters,MetricMassUnit.Kilograms, AngleUnit.Degrees)
    a=MetricUnits(MetricLengthUnit.Meters,MetricMassUnit.Kilograms, AngleUnit.Degrees)
    #a=ImperialUnits(ImperialLengthUnit.Inches,ImperialMassUnit.Pounds,AngleUnit.Degrees)
    
    # Open Document: deformed.stl
    importOptions = ImportOptions.Create()
    
    importOptions.Stl.Units=a
    DocumentOpen.Execute(r"D:\deformed.stl", importOptions)