Page 1 of 1

IDocuments.ImportWithOptions Method

Posted: Wed May 24, 2017 9:51 am
by cam
Hi folks

how can I get the importer Index and associated fileextension (e.g. ".step")
or a list of all importer indexes and the associated fileextensions

Re: IDocuments.ImportWithOptions Method

Posted: Tue May 30, 2017 6:16 pm
by JuP
Hi,

You have to scan all importer and research step.
Example of code for importer searching:

Code: Select all

'Importer searching (Ok)
            Dim Importer As Integer
            Try
                For i = 0 To 50
                    Dim ExitFor As Boolean
                    Dim FileTypeName As String = ""
                    Dim FileExtensions As String() = Nothing
                    TopSolidHost.Application.GetImporterFileType(i, FileTypeName, FileExtensions)       'Importers getting
                    For Each FileExension As String In FileExtensions       'For each importer found
                        FileExension = FileExension.ToUpper()
                        Extension = Extension.ToUpper()
                        If FileExension = Extension Then        'If active importer correspond
                            Importer = i
                            ExitFor = True
                            Exit For
                        End If
                    Next
                    If ExitFor = True Then
                        Exit For
                    End If
                Next
            Catch ex As Exception
                MsgBox("Aucun importer trouvé")
                Me.Close()
                Exit Function
            End Try
"Extension" is juste a string with wich contains your extension like that:

Code: Select all

Dim Extension As String = ".step"
After that you have to use keyvalues for choose importer options, other example:

Code: Select all

Dim ImporterOptions As New List(Of KeyValue)
                Dim KeyValueImplemented As New KeyValue

                KeyValueImplemented.Key = "TRANSLATES_ATTRIBUTES"
                KeyValueImplemented.Value = "True"
                ImporterOptions.Add(KeyValueImplemented)

                KeyValueImplemented.Key = "SIMPLIFIES_GEOMETRY"
                KeyValueImplemented.Value = "False"
                ImporterOptions.Add(KeyValueImplemented)
                
                KeyValueImplemented.Key = "TRANSLATES_FREE_CURVES"
                KeyValueImplemented.Value = "True"
                ImporterOptions.Add(KeyValueImplemented)

                KeyValueImplemented.Key = "TRANSLATES_FREE_SURFACES"
                KeyValueImplemented.Value = "True"
                ImporterOptions.Add(KeyValueImplemented)

                 KeyValueImplemented.Key = "TRANSLATES_HIDDEN_ENTITIES"
                 KeyValueImplemented.Value = "True"
                 ImporterOptions.Add(KeyValueImplemented)
                        
I hope this was helpful

Re: IDocuments.ImportWithOptions Method

Posted: Wed May 31, 2017 11:34 am
by cam
Bonjour Julien,

yes this is very helpful

Merci beaucoup