Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
515 Views, 3 Replies

Write data to part or assembly in iProperty from drawing

Hello

 

I would like to write some information to part or assembly in iProperty from Active Sheet of Drowing.

We use two iProperty in assembly and part. When I make a drawing somethimes i would like to rewrite the actual part iProperty. I have a solution, but this rules write this parameter for all part or assembly of sheets.

 

I would like to use the "DWGViewName" variable in "oActPart" variable, but i dont solv this.

 

'Alkatrészek, összeállítások típusának és a Pót/kopó besorolásoknak a megváltoztatása
'A program egy adott rajzlapon az először lehelyezett modell paramétereit kiolvassa, majd változtatja

'Változók megadása
Dim oSheet As Sheet = ThisDrawing.Document.ActiveSheet

Dim DWGViewName As String
Dim oActPart As Document

Dim DWGType As String
Dim SparePart As String

If Rajz_A_H_Ö_K = "A - alkatrész" Then
	DWGType = "a"
ElseIf Rajz_A_H_Ö_K = "H - hegesztett alkatrész" Then
	DWGType = "h"
ElseIf Rajz_A_H_Ö_K = "Ö - összeállítás" Then
	DWGType = "ö"
ElseIf Rajz_A_H_Ö_K = "K - kerelem" Then
	DWGType = "k"
End If

If Pót_Kopó_alkatrész_P_K = "P - pót alkatrész" Then
	SparePart = "p"
ElseIf Pót_Kopó_alkatrész_P_K = "K - kopó alkatrész" Then
	SparePart = "k"
End If

'ActiveSheet = ThisDrawing.Sheet(oSheet.Name)
If oSheet.TitleBlock Is Nothing Or oSheet.DrawingViews.Count = 0 Then
	MessageBox.Show("Üres rajzfájl, vagy nincs nézet!", "Általános üzenet", MessageBoxButtons.OK, MessageBoxIcon.Information)

Else

'Az éppen aktuális rajz először lehelyezett modell nézetének nevét beolvassa
DWGViewName = ThisDrawing.Document.ActiveSheet.DrawingViews.Item(1).Name
'MessageBox.Show(DWGViewName, "Első nézet neve")

'Az éppen aktuális rajz először lehelyezett modelljét változóba menti
oActPart = oSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument
'MessageBox.Show(oActPart.DisplayName, "Fájlnév")

'Változó elérése és ha nincs beégetése
customPropertySet = oActPart.PropertySets.Item("Inventor User Defined Properties")

Try
	prop = customPropertySet.Item("09. Rajz A/H/Ö/K")
Catch
	customPropertySet.Add("", "09. Rajz A/H/Ö/K")
End Try

oActPart.PropertySets.Item("Inventor User Defined Properties").Item("09. Rajz A/H/Ö/K").Value = DWGType

'Változó elérése és ha nincs beégetése
customPropertySet = oActPart.PropertySets.Item("Inventor User Defined Properties")

Try
	prop = customPropertySet.Item("06. Pót alkatrész / Kopó alkatrész (P/K)")
Catch
	customPropertySet.Add("", "06. Pót alkatrész / Kopó alkatrész (P/K)")
End Try

oActPart.PropertySets.Item("Inventor User Defined Properties").Item("06. Pót alkatrész / Kopó alkatrész (P/K)").Value = SparePart

End If

'ThisApplication.ActiveDocument.Sheets.Item(1).Activate
InventorVb.DocumentUpdate()
ThisDoc.Save

 

I have a saved solution, but I don't use when the part file name is same. These part are in different folder.

 

'Fájl nevének kiolvasásához a változók meghatározása
	Dim DWGViewName As String
	Dim oActPart As String
	Dim oModel As String
	Dim oCurFile As Document
	
	'Az éppen aktuális rajz először lehelyezett modell nézetének nevét beolvassa, majd ez alapján a fájl nevét kiolvassa
	DWGViewName = ThisDrawing.Document.ActiveSheet.DrawingViews.Item(1).Name
	oActPart = ActiveSheet.View(DWGViewName).ModelDocument.FullFileName
	oModel = IO.Path.GetFileName(oActPart)
	
	'A kimentett fájlnév alapján az alábbi tulajdonságokat beírja az alkatrészbe
	iProperties.Value(oModel, "Custom", "QRDstProp")=""
	iProperties.Value(oModel, "Custom", "QRSrcProp")="=[terv] <Stock Number>"
	
	oCurFile = ThisApplication.Documents.Open(oActPart, False)
	oCurFile.Save