SendKeys whit DWG Import

SendKeys whit DWG Import

Anonymous
Not applicable
376 Views
4 Replies
Message 1 of 5

SendKeys whit DWG Import

Anonymous
Not applicable
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 import of dwg file. Thanks to all for any suggestion.
0 Likes
377 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
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.
0 Likes
Message 3 of 5

Anonymous
Not applicable
Thx very mutch Adam i test it.
0 Likes
Message 4 of 5

Anonymous
Not applicable
Hello Adam i'm back.
Your ruotine is awesome and work great, i present you my snowboard...
0 Likes
Message 5 of 5

Anonymous
Not applicable
Adam errata corrige.
The routine work good but if i want to save the file after open the inventor show me an error of automation.

My rutine:
FileSelezionati is an array of path string
...
For i = 0 To UBound(FileSelezionati)
SingoloFile = Cartella & FileSelezionati(i) 'Current file

'OPEN with yout routine
Call ImportaDWG(SingoloFile)

'SAVE in another format
SingoloFileIPT = Left(SingoloFile, Len(SingoloFile) - 3) & "ipt" 'Change extension
Doc.SaveAs SingoloFileIPT, False 'Save and error
Next i

Can you help me?
0 Likes