Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need help to generate a .txt file with some infos extracted from all open assemblies. Besides that I need check if a open file is a iAssembly, if yes I need run the rule for all members of this iAssembly. I wrote the code bellow, but it works just for the assembly that are open.
Dim oAssembly As AssemblyDocument = ThisDoc.Document
Dim oCompDef As AssemblyComponentDefinition = oAssembly.ComponentDefinition
Dim IsiAssembly As Boolean = oCompDef.IsiAssemblyFactory()
Dim factory As iAssemblyFactory = oCompDef.iAssemblyFactory
Dim myList, mySelect As New ArrayList
Dim Instalacao
TolMax = InputBox("Qual a tolerância superior do diâmetro de passagem do parafuso?", "Tolerância Superior")
TolMin = InputBox("Qual a tolerância superior do diâmetro de passagem do parafuso?", "Tolerância Superior")
myList.Add("Cemented")
myList.Add("Screwed")
myList.Add("N/A")
myList_selected = InputListBox("Cimentado, Parafusado ou N/A?", myList, myList(0), Title := "Selecione abaixo", ListName := "List")
mySelect.Add(myList_selected)
For Each Instalacao In mySelect
MessageBox.Show("Arquivo .txt gerado com sucesso! Todos os itens foram definidos como: " & Instalacao, "Sucesso!")
Next
'____Create and write to a text file_________________
oWrite = System.IO.File.CreateText(ThisDoc.Path & "\" & "VerificarConexoes" & ".txt")
'For Each oAssembly In ThisApplication.Documents.VisibleDocuments
For Each assembly As ComponentOccurrence In oCompDef.Occurrences
oAssembly.Activate()
oWrite.WriteLine(item & ";" & Round(A, 2) & ";" & Round(B, 2) & ";" & Round(Emax, 2) & ";" & Round(Emin, 2) & ";" & Instalacao)
If oCompDef.IsiAssemblyFactory() = False Then
item = iProperties.Value("Project", "Part Number")
A = Parameter("Ap")
Emax = Parameter("DIA") + TolMax
Emin = Parameter("DIA") - TolMin
B = Parameter("B")
End If
If oCompDef.IsiAssemblyFactory() = True Then
Dim factoryRows As iAssemblyTableRows = factory.TableRows
For Each row In factoryRows
item = iProperties.Value("Project", "Part Number")
A = Parameter("Ap")
Emax = Parameter("DIA") + TolMax
Emin = Parameter("DIA") - TolMin
B = Parameter("B")
Next
End If
Next
oWrite.Close()
Solved! Go to Solution.