Save as assembly with numbering scheme

Save as assembly with numbering scheme

J.Classens
Enthusiast Enthusiast
525 Views
5 Replies
Message 1 of 6

Save as assembly with numbering scheme

J.Classens
Enthusiast
Enthusiast

Hello, 

 

I have a question about an iLogic rule i wan't to use.

When we download a file (STEP or Assembly) we now have the following sequence:

> Copy the file to the right folder

> Open the STEP or Assy from this folder

> Check in the Assembly 

> Go to folder in de vault 

> Rename the Assembly with the right numbering scheme 

> Get the assembly

 

This process is very time consuming and we need to do it often. 

I found the following iLogic rule i want to use. It was made to export STEP files.

I changed it so it saves to iam. and ipt. files. 

 

'check that the active document is an assembly file
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
    MessageBox.Show("This Rule " & iLogicVb.RuleName & " only works on Assembly Files.", "WRONG DOCUMENT TYPE", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Return
End If

'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oAsmName As String = ThisDoc.FileName(False) 'without extension


'get user input
Dim RUsure = MessageBox.Show(
"This will create a STEP file for all components." _
& vbLf & " " _
& vbLf & "Are you sure you want to create STEP Drawings for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic - Batch Output STEPs ", MessageBoxButtons.YesNo)
If RUsure = vbNo Then
    Return
Else
End If

'- - - - - - - - - - - - -STEP setup - - - - - - - - - - - -
Dim oPath = ThisDoc.Path
'get STEP target folder path
' original => oFolder = oPath & "\" & oAsmName & " STEP Files"
Dim oFolder = oPath & "\STEP Files"
'Check for the step folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
    System.IO.Directory.CreateDirectory(oFolder)
End If


'- - - - - - - - - - - - -Assembly - - - - - - - - - - - -
ThisDoc.Document.SaveAs(oFolder & "\" & oAsmName & (".iam"), True)

'- - - - - - - - - - - - -Components - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments
'work the referenced models
For Each oRefDoc As Document In oRefDocs
    Dim oCurFile As Document = ThisApplication.Documents.Open(oRefDoc.FullFileName, True)
    Dim oCurFileName = oCurFile.FullFileName
    Dim ShortName = IO.Path.GetFileNameWithoutExtension(oCurFileName)

    Dim oPropSets As PropertySets = oCurFile.PropertySets
    Dim oPropSet As PropertySet = oPropSets.Item("Design Tracking Properties")
    Dim oPartNumiProp As [Property] = oPropSet.Item("Part Number")


    Try
        oCurFile.SaveAs(oFolder & "\" & oPartNumiProp.Value & (".ipt"), True)
    Catch
        MessageBox.Show("Error processing " & oCurFileName, "ilogic")
    End Try
    oCurFile.Close()
Next
'- - - - - - - - - - - - -
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic")

 

I want to change two things but i can't get it to work.

 

1: It now uses the partnumber for the new filename. I want to use a numbering scheme to generate a number for this name. Is there a possibility to acces the numbering scheme to do this? I can't find out where to start. 

 

2:  It now saves the file in a subfolder from the original file (/STEP). I want to change it so the engineer can choose a  folder from a pull down menu. The location is as following: C:\Manders Vault\Designs\03 MAP - Manders Purchase\Festo . The last part of the location (Festo) is what i want to choose with a pull down menu. 

The data i want to use in the pull down menu is stored in a excel file. Is this possible to do? 

 

This shoud give me the following sequence:

> Open the Assembly STEP from download folder

> Run the iLogic rule

> Choose the correct folder

> Ready

 

 

0 Likes
526 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

For the step import you can use a translator rule to import the specific step file type. 

Here is a link to the API help. You will need to change the adding reference for the file type in question. You can customize the settings then instead of manual approach. If you have a common file type you import let us know. I have a .stp import I can share if that helps.

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

J.Classens
Enthusiast
Enthusiast

The files we open are depending on the supplier. Sometimes it are already Inventor files, sometimes other files like STEP.

This is why I use an export function to open the file and export it to a inventor file with the right filename. The only problem is  that the filename it uses is the part numbering and i want to use the numbering scheme. 

 

Maybe if there is an import function that reads all the filetypes i can use to do the trick. Or does it only imports one type?

0 Likes
Message 4 of 6

A.Acheson
Mentor
Mentor

If you are not using an import rule for step file then that will be another task in itself. As there will be options required for each import etc.

 

 

The rule below will take care of pulling in a folder name for selection. Where you place the drop down will depend on how you will launch this rule. Using the rule a drop down list will pop up. I have commented out the excel import. You can use this in place of the built in arraylist  FolderNames.Add("Festo"). You will just need to integrate it into your original rule. 

Dim FolderNames As New ArrayList
Dim FolderName As String

Dim oPath As String
oPath = "R:\Groups\Corix Water Systems\CWS ENGINEERED SYSTEMS\Alan Acheson\QUOTES"

'Create the list to be used in a drop down
FolderNames.Add("Festo")
FolderNames.Add("New1")
FolderNames.Add("New2")

alternatively take the List from excel
'FolderNames = GoExcel.CellValues("filename.xls", "Sheet1", "A2", "A10")

FolderName = InputListBox("Prompt", FolderNames, d0, Title := "Title", ListName := "List")

Dim NewPath As String
NewPath = oPath & "\" & FolderName

MessageBox.Show(NewPath, "NewPath")

Some more answer in red to the original questions:

When we download a file (STEP or Assembly) we now have the following sequence:

> Copy the file to the right folder

> Open the STEP or Assy from this folder

> Check in the Assembly ' I have no experience in this, consider search this forum or vault forum for examples.

> Go to folder in de vault ' I have no experience in this, consider search this forum or vault forum for examples.

> Rename the Assembly with the right numbering scheme 'Number scheme from vault ,  consider search this forum or vault forum for examples. I think this would be difficult to do. it might be better do the renaming in vault. 

> Get the assembly ' I have no experience in this, consider search this forum or vault forum for examples.

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 6

J.Classens
Enthusiast
Enthusiast

@A.Acheson Thanks! The list snippet works perfect 👌

 

The numbering scheme is the only problem i still have.

The next snippet works to get numbers from the numbering scheme.

Sub Main
	'CCNS is the name of my numberingscheme, you'll have to put in yours below instead.
	getFilenamesFromVaultNamingScheme("Manders Purchase", "", 1)
End Sub

Public Sub getFilenamesFromVaultNamingScheme(RequiredSchemeName As String, RequiredSchemeString As String, numberOfNames As Integer)
Dim Connection As VDF.Vault.Currency.Connections.Connection = edm.EdmSecurity.Instance.VaultConnection()
Dim genNum As String = String.Empty
Dim first As String
Dim last As String
If Not Connection Is Nothing Then
Dim entityClassId = VDF.Vault.Currency.Entities.EntityClassIds.Files
Dim numSchemes As ACW.NumSchm() = Connection.WebServiceManager.NumberingService.GetNumberingSchemes(entityClassId, Nothing) 'kanske inte nothing
Dim requiredScheme As ACW.NumSchm = (From sch As ACW.NumSchm In numSchemes
Where sch.Name = RequiredSchemeName
Select sch).FirstOrDefault()
Dim numGenArgs() As String = {RequiredSchemeString }
For i = 1 To numberOfNames
	genNum = Connection.WebServiceManager.DocumentService.GenerateFileNumber(requiredScheme.SchmID, numGenArgs)
	If i = 1 Then first = genNum
	If i = numberOfNames Then last = genNum
Next
MessageBox.Show("Numbers generated: " & first & " to " & last, "Success!", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Vault didn't work", "Fail!", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub

 

I need the numbers that are generated to be put in the file name (see red text).

'- - - - - - - - - - - - -Assembly - - - - - - - - - - - -

ThisDoc.Document.SaveAs(oFolder & "\" & oAsmName & (".iam"), False)

'- - - - - - - - - - - - -Components - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments
'work the referenced models
For Each oRefDoc As Document In oRefDocs
    Dim oCurFile As Document = ThisApplication.Documents.Open(oRefDoc.FullFileName, False)
    Dim oCurFileName = oCurFile.FullFileName
    Dim ShortName = IO.Path.GetFileNameWithoutExtension(oCurFileName)

    Dim oPropSets As PropertySets = oCurFile.PropertySets
    Dim oPropSet As PropertySet = oPropSets.Item("Design Tracking Properties")
    Dim oPartNumiProp As [Property] = oPropSet.Item("Part Number")


    Try
        oCurFile.SaveAs(oFolder & "\" & ShortName & (".ipt"), False)
    Catch
        MessageBox.Show("Error processing " & oCurFileName, "ilogic")
    End Try
    oCurFile.Close()
Next
'- - - - - - - - - - - - -

 Is the a possibility to get this to work? I can't figure out how it needs to be done. 

0 Likes
Message 6 of 6

A.Acheson
Mentor
Mentor

To start with you will need to know how many numbers to retrieve from vault. You can do that by counting the documents in the assembly. Here is the link to that method.

 

Then you will need to index through the list of string retrieved from the vault and retrieve the next number. Here is a link to retrieve an indexed number from an arraylist

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes