I reshape my rules, thanks to your contributions.
Here is my main rule:
RRFA=MessageBox.Show("Bu komutu çalıştırmadan önce tüm CHECKOUT'ları almış olmanız gerekmektedir. Eğer checkout almadıysanız lütfen işlemi iptal ederek checkout alın. Referans olarak çekilmiş .stp parçalar montajda var ise program hata verecektir. Devam edilsin mi?", "ÇOK ÖNEMLİ UYARI",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)
If RRFA = vbYes Then
RRFA2= MessageBox.Show("Tüm montaj için parametreleri eklemeye başlamak üzeresiniz. İşlem süresince Inventor'e müdahale etmeyiniz. Checkout'u sizde olmayan parçalar açıldıktan sonra kapanmayacaktır. Montajın büyüklüğüne göre işlem süresi çok uzun olabilir. Devam etmek istediğinize emin misiniz ?", "Köprüden Önceki Son Çıkış",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)
If RRFA2 = vbYes Then
Dim oDoc As Document
oDoc = ThisDoc.Document
'Dim oDoc As AssemblyDocument
'oDoc = ThisApplication.ActiveDocument
If Not ThisApplication.ActiveDocument.DocumentType = kAssemblyDocumentObject Then
Return
End If
'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In oDoc.AllReferencedDocuments
ThisApplication.Documents.Open(docFile.FullFileName, True)
'iLogicVb.RunExternalRule("PCustomUser")
iLogicVb.RunExternalRule("RunRuleForAll2")
docFile.Save
docFile.Close
Next
MessageBox.Show("İşlem tamamlandı.", "Mutlu Son")
Else
MessageBox.Show("İşlem iptal edildi.", "ÇOK ÖNEMLİ UYARI")
End If
Else
MessageBox.Show("İşlem iptal edildi.", "ÇOK ÖNEMLİ UYARI")
End If
iLogicVb.UpdateWhenDone = True
Here is second rule RunRuleForAll2
'Msj= MessageBox.Show("Bu makroyu halihazırda mevcut olan TR-EN montaj ve partlar için çalıştırırsanız olmayan parametreler eklenir ve eski antetten yeni antete aktarım yapılır. Önceden tanımlanmış olanlar olduğu gibi kalır. Devam etmek istediğinize emin misiniz ?", "Son Karar",MessageBoxButtons.YesNo)
'If Msj = vbYes Then
customPropertySet = ThisApplication.ActiveDocument.PropertySets.Item("Inventor User Defined Properties")
Dim PropertyName As String()
Dim propertyValue As String
PropertyName = {"CHardness", "SHardness", "Hblack", "HGreen", "MRed", "MBlack", "SBlue","Quantity", "StockNo_2", "StockNo_3", "StockNo_4", "StockDef1", "StockDef2", "StockDef3", "StockDef4", "Quantity", "Title_2", "Subject_2"}
propertyValue= ""
Dim a As Integer = 0
While a < PropertyName.Count
Try
prop = customPropertySet.Item(PropertyName(a))
Catch
customPropertySet.Add("", PropertyName(a))
customPropertySet.Item(PropertyName(a)).Value = propertyValue
End Try
a = a+1
End While
'-----------------------------
Dim PropertyName18 As String = "ToleranceClass"
Dim propertyValue1 As String = "ISO 2768 CL"
Try
prop = customPropertySet.Item(PropertyName18)
Catch
customPropertySet.Add("", PropertyName18)
iProperties.Value("Custom", PropertyName18) = propertyValue1
End Try
'-----------------------------------------------------------------------------------------
'Name=ThisApplication.ActiveDocument.FullDocumentName
' Dim name1 As String
'name1=ThisDoc.FileName(True) 'without extension
customPropertySet1 = ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties")
customPropertySet2 = ThisApplication.ActiveDocument.PropertySets.Item("Document Summary Information")
customPropertySet.Item("StockNo_2").Value = customPropertySet1.Item("Authority").Value
customPropertySet.Item("StockNo_3").Value = customPropertySet2.Item("Category").Value
customPropertySet.Item("Quantity").Value = customPropertySet1.Item("Catalog Web Link").Value
'KONTROL EDEN TANIMLAMA - TASARIMCININ APPLICATION OPTION'DAKI USER NAME'İNE GÖRE BELİRLEMEKTEDİR.
ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties").Item("Designer").Value=ThisApplication.GeneralOptions.UserName
Dim Designer As String
Designer=ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties").Item("Designer").Value
Dim Designers()={"Okan Murat", "Tayfun Ayyıldız", "Ömür Yıldırım", "Barış Kök", "Engin Oylukan", "Gençay Genç", "Hakan Gümüş", "Recep Başaran"}', "Mustafa Güner"}
Dim MaxCount As Integer
Dim Counter As Integer
i = 0
MaxCount = 7
For Counter=i To MaxCount
If Designer = Designers(i) Then
ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties").Item("Checked By").Value = "Recep Gümrük"
Else
ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties").Item("Checked By").Value = "Zülkani Durmuş"
End If
i = i + 1
Next
'KONTROL EDEN TANIMLAMA SON
ThisApplication.ActiveDocument.PropertySets.Item("Inventor Document Summary Information").Item("Manager").Value = "Mehmet Evrenosoğlu"
'Mevcutsa aktarım:
'MessageBox.Show("Message", "Title")
Try
customPropertySet.Item("Title_2").Value = customPropertySet2.Item("Company").Value
Catch
End Try
Try
customPropertySet.Item("Subject_2").Value = customPropertySet.Item("ASSM.NAME").Value
Catch
End Try
'---------------------------------------------------------------------------------------------
Dim ParamValue2 As Double = 0
Dim ParamName2 = "Alan"
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
Dim oParams As Parameters = oCD.Parameters
Dim oUserParams As UserParameters = oParams.UserParameters
Try
oParams(ParamName2).Value = ParamValue2
Catch
Dim newparam As UserParameter= oUserParams.AddByExpression(ParamName2, ParamValue2, "m^2")
'oParams(ParamName2).Expression = iProperties.Area
oParams(ParamName2).Value= iProperties.Area
newparam.ExposedAsProperty=True
'oParams.IsKey=True
'oUserParams.AddByValue(ParamName,6,11270)
End Try
'--------------------------------------------------------
oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
Dim Parameters As String()
Parameters = {"Mass", "Material", "SDef1", "SDef2", "SDef3", "SDef4"}
ParameterVal = {"", "", "", "", "", ""}
Dim j As Integer = 0
While j < Parameters.Count
Try
Params = oMyParameter(Parameters(j)) ' Asking if this Parameter exists
Catch
Params = oMyParameter.AddByValue(Parameters(j), "", UnitsTypeEnum.kTextUnits) ' If not create this parameter
'Params.Iskey=True
End Try
j = j+1
End While
Parameter.UpdateAfterChange = True
iLogicVb.UpdateWhenDone = True
ThisDoc.Save
iLogicVb.RunExternalRule("StokTanım")
'MessageBox.Show("Olmayan parametreler eklendi ve eski antetten yeni antete aktarım yapıldı. Her şey sen daha mutlu ol diye el birliği ile çalışıyor farkında mısın ?" & vbNewLine & vbNewLine & "STOK TANIMLAMALARINI DEĞİŞTİRMEYİ UNUTMA !!!", "Yaşıyorsun Şu Hayatı", MessageBoxButtons.OK)
'MessageBox.Show("Stok tanımlamala", "Yaşıyorsun Şu Hayatı", MessageBoxButtons.OK)
Parameter.UpdateAfterChange = True
iLogicVb.UpdateWhenDone = True
ThisApplication.ActiveDocument.Save
'-----------------------------
'Else
'MessageBox.Show("İşlem iptal edildi.", "Peki...",MessageBoxButtons.OK)
'End If
Finally last Rule StokTanım:
oMyParameter = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
oCustomPropertySet = ThisApplication.ActiveDocument.PropertySets.Item("Inventor User Defined Properties")
MultiValue.SetList("SDef1", "", "Stok Numarası Stock No", "Boyalı SN Painted SN", "Kaynaklı SN Welded SN", "Talaşlı SN Machining SN",
"Kaplama SN Coating SN","Montaj SN Assembly SN")
MultiValue.SetList("SDef2", "", "Stok Numarası Stock No", "Boyalı SN Painted SN", "Kaynaklı SN Welded SN", "Talaşlı SN Machining SN",
"Kaplama SN Coating SN","Montaj SN Assembly SN")
MultiValue.SetList("SDef3", "", "Stok Numarası Stock No", "Boyalı SN Painted SN", "Kaynaklı SN Welded SN", "Talaşlı SN Machining SN",
"Kaplama SN Coating SN","Montaj SN Assembly SN")
MultiValue.SetList("SDef4", "", "Stok Numarası Stock No", "Boyalı SN Painted SN", "Kaynaklı SN Welded SN", "Talaşlı SN Machining SN",
"Kaplama SN Coating SN","Montaj SN Assembly SN")
oCustomPropertySet.Item("StockDef1").Value = oMyParameter("SDef1")
oCustomPropertySet.Item("StockDef2").Value = oMyParameter("SDef1")
oCustomPropertySet.Item("StockDef3").Value = oMyParameter("SDef2")
oCustomPropertySet.Item("StockDef4").Value = oMyParameter("SDef3")
'set custom property value
'iProperties.Value("Custom", "StockDef3") = Parameter.Value("SDef3")
'iProperties.Value("Custom", "StockDef4") =Parameter.Value("SDef4")
'iLogicVb.RunExternalRule("Alan")
Parameter("Alan") = iProperties.Area
Parameter("Material") = iProperties.Material
Parameter("Mass")= iProperties.Mass
iLogicVb.UpdateWhenDone = True
iLogicVb.UpdateWhenDone = True
As you can guess i am getting errors.