Bonjour
Pour les 2 premiers j'ai ça déjà en production on va dire
Pour le troisième pratiquement sauf que j'ai fait un système qui permet de sélectionner la vue, récupérer le nom de la vue et s'en servir pour nommer le fichier.
Par contre tout est en VBA mais facilement transposable en ilogic.
Export DWG avec un fichier ini à configurer
Public Sub DWGOutUsingTranslatorAddIn(DWGName As String, DWGDirectory As String, DWGConfiguration 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
' Create the name-value that specifies
' the ini file to use.
Call oNameValueMap.Add("Export_Acad_IniFile", DWGConfiguration)
' 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
' Define the type of output by
' specifying the filename.
Dim oOutputFile As DataMedium
Set oOutputFile = ThisApplication.TransientObjects.CreateDataMedium
oOutputFile.filename = DWGDirectory & DWGName & ".dwg"
' Call the SaveCopyAs method of the add-in.
Call oDWGAddIn.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oNameValueMap, oOutputFile)
End Sub
Export IGES (faut regarder la version STP qui doit trainer sur les forums)
Function Export2IGES(sViewName, sDirectory As String)
Set oModelDoc = ThisApplication.ActiveDocument
'set translator options
Set oIGESTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F44-0C01-11D5-8E83-0010B541CD80}")
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
'Set export path
Dim sPath As String
oDataMedium.MediumType = kFileNameMedium
'Set export file name
oDataMedium.filename = sDirectory & "\" & sViewName & " - " & GetThickness & ".igs"
If oIGESTranslator.HasSaveCopyAsOptions(oModelDoc, oContext, oOptions) Then
' Set geometry type for wireframe.
' 0 = Surfaces, 1 = Solids, 2 = Wireframe
oOptions.value("GeometryType") = 1
' To set other translator values:
' oOptions.Value("SolidFaceType") = n
' 0 = NURBS, 1 = Analytic
' oOptions.Value("SurfaceType") = n
' 0 = 143(Bounded), 1 = 144(Trimmed)
'Use Export To IGES to save drawing configuration and set here
'Dim strIniFile As String = "C:\IGES\ConfigurationFile.ini"
' Create the name-value that specifies the ini file to use.
'oOptions.Value("Export_Acad_IniFile") = strIniFile
'Save File
Call oIGESTranslator.SaveCopyAs(oModelDoc, oContext, oOptions, oDataMedium)
End If
End Function
Pour récupérer l'épaisseur des tôles, on s'en sert pour nommer le fichier d'export ça aide notre fournisseur à faire ses prix
Function GetThickness()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
' Make sure the document is a sheet metal document.
If oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Dim oSheetMetalCompDef As SheetMetalComponentDefinition
Set oSheetMetalCompDef = oPartDoc.ComponentDefinition
GetThickness = oSheetMetalCompDef.Thickness.ModelValue * 10 & "mm" 'L'unité de base est le cm... Logique Autodesk...
Else
Dim sThickness As String
sThickness = InputBox("Veuillez entrer l'épaisseur de la tôle sans unité", "Epaisseur de la tôle")
If sThickness <> "" Then
GetThickness = sThickness
Else
MsgBox "Vous n'avez pas précisé d'épaisseur, la valeur est forcée à Xmm"
GetThickness = "X"
End If
End If
End Function