Hello fazzini,
Via the user interface you can create a settings file, which could be used
later on.
I would suggest implementing the import functionality through the dwg import/export
AddIn.
Here is a sample:
Public Sub OpenDWGTest()
' Calls a function that uses the DWG translator directly. This allows
' you to specify some more options. In this case it's specifying the
' ini file to use that contains all of the various options.
Call DWGInUsingTranslatorAddIn("C:\Temp\Test2.dwg")
End Sub
Public Sub DWGInUsingTranslatorAddIn(DWGFilename As String)
' Set a reference to the DWG translator add-in.
Dim oDWGAddIn As TranslatorAddIn
Dim i As Long
For i = 1 To ThisApplication.ApplicationAddIns.Count
If ThisApplication.ApplicationAddIns.Item(i).ClassIdString = "{C24E3AC2-122E-11D5-8E91-0010B541CD80}"
Then
Set oDWGAddIn = ThisApplication.ApplicationAddIns.Item(i)
Exit For
End If
Next
If oDWGAddIn Is Nothing Then
MsgBox "The DWG add-in could not be found."
Exit Sub
End If
' Check to make sure the add-in is activated.
If Not oDWGAddIn.Activated Then
oDWGAddIn.Activate
End If
' Create a name-value map to supply information to the translator.
Dim oNameValueMap As NameValueMap
Set oNameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
Dim strIniFile As String
strIniFile = "C:\temp\DWGImport.ini"
' Create the name-value that specifies the ini file to use.
Call oNameValueMap.Add("Import_Acad_IniFile", strIniFile)
' Create a translation context and define that we want to output to a file.
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
' Set filename in registry
Const HKEY_CURRENT_USER = &H80000001
Dim strComputer, strKeyPath, objRegistry
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Autodesk\Inventor\RegistryVersion10.0\Translators\DWG\Last
INI file"
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, "Last Export DWG
INI file", strIniFile
ThisApplication.SilentOperation = True
' Define the type of output by specifying the filename.
Dim oInputFile As DataMedium
Set oInputFile = ThisApplication.TransientObjects.CreateDataMedium
oInputFile.FileName = DWGFilename
' Call the SaveCopyAs method of the add-in.
Call oDWGAddIn.Open(oInputFile, oContext, oNameValueMap, Nothing)
ThisApplication.SilentOperation = False
End Sub
Cheers,
Adam
> Hello to all.
> Is possible to use the SendKeys method for interact with the wizard
> window
> which show in the open command? I want to use this command for
> multiple imp
> ort of dwg file. Thanks to all for any suggestion.