Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is that possible to Create a button on Vault to create Step file and STL file with choosing the location to save ?

3 REPLIES 3
Reply
Message 1 of 4
daniel.li89M5L
571 Views, 3 Replies

Is that possible to Create a button on Vault to create Step file and STL file with choosing the location to save ?

Is that possible to Create a button on Vault to create Step file and STL file with choosing the location ?

 

Any thought will help

 

Thank you!

 

3 REPLIES 3
Message 2 of 4
s.haseborg
in reply to: daniel.li89M5L

Hi,

you could define a new custom command which calls up a file location browser. The selected path you can store in a job parameter (e.g. FileLocation). With this you can create a new custom job.

Than you have to code your own job processor (step, STL) which will use the job parameter "FileLocation" to store the file in the choosen path.

 

Code snippet (VB.Net) for Command:

Dim obj_JobParam_FileLocation As Autodesk.Connectivity.WebServices.JobParam = New ACW.JobParam
obj_JobParam_FileLocation.Name = "FileLocation"
obj_JobParam_FileLocation.Val = str_SelectedPath

...

Dim obj_JobParam() As ACW.JobParam = {obj_JobParam_FileLocation} 'Even more parameters are needed!

obj_Jobservice = obj_Context.Application.Connection.WebServiceManager.JobService
obj_Jobservice.AddJob(str_JobName, str_Comment, obj_JobParam, int_Priority)

 

Code Snippet for Job Processor:

...

Dim str_SelectedPath as String = job.Params("FileLocation") 'Gets the parameter from the Job

...

 

Kind Regards

Stefan

 

Message 3 of 4
daniel.li89M5L
in reply to: s.haseborg

Thank you s.hasebrog for your reply!

I used the Helloworld document as reference from the  SKD folder.  Would you mind to show me how to make change  on Helloworld document to  save STEP file and STL file though the Translator? Thank you!

 

Best Regard,

 

Daniel

Message 4 of 4
s.haseborg
in reply to: daniel.li89M5L

Hello Daniel,

 

the "HelloWorld" example shows you how to implement an custom command to Vault. To "fire" an own job you have to do several things.

 

1. Create a command in Vault

Based on the example from the SDK you have to execute a job creation. For this you need the jobservice and the job parameters, here is an example with an optional parameter for the export path (not tested). 

 

Private Sub MakeJob(FileFilterType() As String, DestType As String, JobName As String, Comment As String, Priority As Integer, Context As Autodesk.Connectivity.Explorer.Extensibility.ICommandContext, Optional ExportFilePath As String = "c:\temp")

 

obj_Jobservice As ACW.JobService

 

'iterate all selected files and get the file
For Each obj_Select As ISelection In Context.CurrentSelectionSet
If FilterType.Any(Function(n) Strings.LCase(System.IO.Path.GetExtension(obj_Select.Label)).Contains(n)) Then
Dim obj_File As ACW.File = Nothing

If obj_Select.TypeId.SelectionContext <> "FileMaster" Then
obj_File = Context.Application.Connection.WebServiceManager.DocumentService.GetLatestFilesByIds(New Long() {obj_Select.Id}).FirstOrDefault
Else
obj_File = Context.Application.Connection.WebServiceManager.DocumentService.GetLatestFilesByMasterIds(New Long() {obj_Select.Id}).FirstOrDefault
End If

 

'create parameters for job

Dim obj_JobParam_1 As Autodesk.Connectivity.WebServices.JobParam = New ACW.JobParam
obj_JobParam_1.Name = "FileMasterId"
obj_JobParam_1.Val = obj_File.MasterId

Dim obj_JobParam_2 As Autodesk.Connectivity.WebServices.JobParam = New ACW.JobParam
obj_JobParam_2.Name = "FileName"
obj_JobParam_2.Val = obj_Select.Label

Dim obj_JobParam_3 As Autodesk.Connectivity.WebServices.JobParam = New ACW.JobParam
obj_JobParam_3.Name = "EntityId"
obj_JobParam_3.Val = obj_File.Id

Dim obj_JobParam_4 As Autodesk.Connectivity.WebServices.JobParam = New ACW.JobParam
obj_JobParam_4.Name = "EntityClassId"
obj_JobParam_4.Val = "File"

Dim obj_JobParam_5 As Autodesk.Connectivity.WebServices.JobParam = New ACW.JobParam
obj_JobParam_5.Name = "FileVersionId"
obj_JobParam_5.Val = obj_File.Id

Dim obj_JobParam_6 As Autodesk.Connectivity.WebServices.JobParam = New ACW.JobParam
obj_JobParam_6.Name = "UpdateViewOption"
obj_JobParam_6.Val = "False"

Dim obj_JobParam_7 As Autodesk.Connectivity.WebServices.JobParam = New ACW.JobParam
obj_JobParam_7.Name = "FileId"
obj_JobParam_7.Val = obj_File.Id

Dim obj_JobParam_8 As Autodesk.Connectivity.WebServices.JobParam = New ACW.JobParam
obj_JobParam_8.Name = "ExportFilePath"
obj_JobParam_8.Val = ExportFilePath

 

Dim obj_JobParam() As ACW.JobParam = {obj_JobParam_1, obj_JobParam_2, obj_JobParam_3, obj_JobParam_4, obj_JobParam_5, obj_JobParam_6, obj_JobParam_7, obj_JobParam_8}

 

obj_Jobservice = obj_Context.Application.Connection.WebServiceManager.JobService

 

'try to create a job
Try
obj_Jobservice.AddJob(JobName, Comment & obj_JobParam_2.Val, obj_JobParam, Priority)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MsgBox("Für das Dateiformat '" & Strings.LCase(System.IO.Path.GetExtension(obj_Select.Label)) & "' kann keine " & DestType & " erzeugt werden.", MsgBoxStyle.Information, "Konvertierungsauftrag erstellen")
End If
Next
End Sub

 

2. Create a job handler

To handle your custom job you have to create a job handler. Take a look into the APIHelp in the SDK Folder "Getting started -> How to create custom jobs". For the inventor addin call you can use the Inventor API help.

 

In the execution handler for your custom job you can use the parameter "ExportFilePath" as path to save the created step file.

 

Public Function Execute(context As ACJE.IJobProcessorServices, job As ACJE.IJob) As ACJE.JobOutcome Implements IJobHandler.Execute

'...

'... you have to accuire the needed files from Vault, look into SDK help for that

'... get the Filepath and Filename out of the Vault File object and save to str_FileName and str_FolderName

'...

 

Dim str_ExportFileName as String = job.Params("ExportFilePath")

Dim obj_InvApp As Inventor.InventorServer = Context.InventorObject
Dim obj_InvDoc As Inventor.Document = Nothing

 

Try
If obj_InvApp Is Nothing Then
Context.Errors.Add("could not start Inventor server")
Return ACJE.JobOutcome.Failure
End If

 

'Get Inventor doc
obj_InvDoc = obj_InvApp.Documents.Open(str_FolderName & str_FileName, False)
If obj_InvDoc Is Nothing Then
Context.Errors.Add("Dcould not open Inventor document")
Return ACJE.JobOutcome.Failure
End If

 

'get Step AddIn
Dim obj_STEPAddin As Inventor.ApplicationAddIn = obj_InvApp.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
Dim obj_TransContext As Inventor.TranslationContext = obj_InvApp.TransientObjects.CreateTranslationContext
Dim obj_TransOptions As Inventor.NameValueMap = obj_InvApp.TransientObjects.CreateNameValueMap

 

'create Stepfile
With obj_TransOptions
.Value("ApplicationProtocolType") = 5 'Step 242
.Value("Author") = "JobProzessor"
.Value("Organization") = "Your Company"
.Value("Description") = "Your Descrition"
End With

 

Try
obj_TransContext.Type = Inventor.IOMechanismEnum.kFileBrowseIOMechanism
Dim obj_Data As Inventor.DataMedium = obj_InvApp.TransientObjects.CreateDataMedium
obj_Data.FileName = str_ExportFileName & System.IO.Path.GetFileNameWithoutExtension(str_FileName) & ".stp"
obj_STEPAddin.SaveCopyAs(obj_InvDoc, obj_TransContext, obj_TransOptions, obj_Data)

Catch Ex as Exception

Return ACJE.JobOutcome.Failure

End Try

Return ACJE.JobOutcome.Success

 

End Function

 

This snippet is not tested yet, but I think it should work. You have to do some extra work to collect the needed files from Vault. The SDK help files will guide you for that. Look for "How to Aquire Files".

 

Hope this will help you a bit.

 

Regards

Stefan

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report