iLogic to create autocad DWG

iLogic to create autocad DWG

Anonymous
Not applicable
1,918 Views
2 Replies
Message 1 of 3

iLogic to create autocad DWG

Anonymous
Not applicable

Hello,

 

I found and modify slightly a code below which is working very good for me but i would like to add Yes/No message box.
Can anyone have a look and help me with this??

 

 

Imports SysIO = System.IO
Sub Main()
'See if there are any open views
If (ThisApplication.Views.Count > 0) Then
'Setup Translator to dwg
Dim DWGAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
'Go through each view and save if it's a drawing document
For Each view As View In ThisApplication.Views
If view.Document.DocumentType = kDrawingDocumentObject Then
'Get the directory file is saved in. Can replace this with specific directory
Workspacepath = ThisDoc.WorkspacePath ()

WorkspacePathLength = Len (Workspacepath)

Pathonly = ThisDoc.Path

Directorypath = strings.right(pathonly, pathonly.length-WorkspacePathLength)

DWGPath = "\\VPE-SERVER\Drawings\" & Directorypath

If(Not System.IO.Directory.Exists(DWGPath))Then
    System.IO.Directory.CreateDirectory(DWGPath)
End If
Dim dwgDir = DWGPath
'Get name of file without the extension and add _acad2k to it.
oDataMedium.MediumType = kFileNameMedium
oDataMedium.FileName = dwgDir & "\\" & _
 SysIO.Path.GetFileNameWithoutExtension(view.Document.FullFileName) & _
 "_acad2k.dwg"
' Check whether the translator has 'SaveCopyAs' options
If DWGAddIn.HasSaveCopyAsOptions(view.Document, oContext, oOptions) Then
'Use Export To DWG to save drawing configuration and set here
Dim strIniFile As String = "\\VPE-SERVER\Drawings\Template\Inventor\Templates\DWGOut.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
'Save File
DWGAddIn.SaveCopyAs(view.Document, oContext, oOptions, oDataMedium)
End If
End If
Next
End If


  
End Sub

 

0 Likes
Accepted solutions (1)
1,919 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor
Accepted solution
If MsgBox("Create DWG?" & vblf & vblf & oFileName, MsgBoxStyle.YesNo, "DWG CREATER TITLE") = MsgBoxResult.Yes

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 3

Anonymous
Not applicable

Thanks for your help it working good for me.

0 Likes