Purge DWG items when exporting from IV - ilogic

Purge DWG items when exporting from IV - ilogic

tuliobarata
Advocate Advocate
529 Views
1 Reply
Message 1 of 2

Purge DWG items when exporting from IV - ilogic

tuliobarata
Advocate
Advocate

Hey all again,

 

Here im with the following code, that I use to export my iIDW to DWG, but, in my design data i got many styles that i dont use in every IDW, so in someones they are useless, and even useless, they go to the DGW version (like many layers that isnt in use in the drawing).

Now the question, is there a way to purge the document while it is exported from Inventor ?

Because its a little annoying to enter in every DWG file and purge them. The main problem here is the size of files, to send to the client (a request from them, the DWG... not PDF :S )

 

I'm using this code to export:

 

'------- start of iLogic code ------------------------------------------------------------------------------------------------------------------------------------- ' Get the DWG translator Add-In. Dim DWGAddIn As TranslatorAddIn 
DWGAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{C24E3AC4-122E-11D5-8E91-0010B541CD80}") 

'Set a reference to the active document Dim oDocument As Document 
oDocument = ThisApplication.ActiveDocument 
Dim oContext As TranslationContext 
oContext = ThisApplication.TransientObjects.CreateTranslationContext 
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism 
' Create a NameValueMap object Dim oOptions As NameValueMap 
oOptions = ThisApplication.TransientObjects.CreateNameValueMap 

' Create a DataMedium object Dim oDataMedium As DataMedium 
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 

' Check whether the translator has 'SaveCopyAs' options If DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then 
    ' DWG version.    ' 23 = ACAD 2000    ' 25 = ACAD 2004    ' 27 = ACAD 2007    ' 29 = ACAD 2010     oOptions.Value("DwgVersion") = 29
Dim strIniFile As String 
strIniFile = "X:\10-ARQUIVOS INVENTOR\00-Inventor\00 - Inventor 2013\Configuration Files - DWG.ini" 
' Create the name-value that specifies the ini file to use. oOptions.Value("Export_Acad_IniFile") = strIniFile 
End If 

'get path and file namepath_and_name = ThisDoc.PathAndFileName(False) ' without extension
'Set the DWG target file nameoDataMedium.FileName = path_and_name & ".DWG"
DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) 
'------- end of iLogic code ----------------------------------------------------------------------------------------------------------------------------

 Thanks very much!

 

Tulio Barata

IV 2013
0 Likes
530 Views
1 Reply
Reply (1)
Message 2 of 2

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

About purge styles, you could either execute the built-in command by

  

CommandManager.ControlDefinitions("PurgeStylesCmd").Execute

 

or delete the style if it is NOT in use. e.g.

 

Sub replaceAndpurge() 

Dim oDoc As DrawingDocument 
Set oDoc = ThisApplication.ActiveDocument 

Dim oStyleManager As DrawingStylesManager 
Set oStyleManager = oDoc.StylesManager 

Dim oBalloonStyle1 As BalloonStyle 
Set oBalloonStyle1 = oStyleManager.BalloonStyles("Copy of Balloon (ANSI)") 

Dim oBalloonStyle2 As BalloonStyle 
Set oBalloonStyle2 = oStyleManager.BalloonStyles("Balloon (ANSI)") 

'replace 
oStyleManager.ObjectDefaultsStyles(1).BalloonStyle = oBalloonStyle2 


'purge 
If oBalloonStyle1.InUse And oBalloonStyle1.StyleLocation = kLocalStyleLocation Then 
oStyle.Delete 
End If 


End Sub

 

0 Likes