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

Write data to part or assembly in iProperty from drawing

Anonymous

Write data to part or assembly in iProperty from drawing

Anonymous
Not applicable

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

 

0 Likes
Reply
Accepted solutions (1)
513 Views
3 Replies
Replies (3)

bradeneuropeArthur
Mentor
Mentor

Hi,

 

What property you would like to re-write, from the drawing to the part or assembly?

You don't need it in reverse?

Could you give me a property name?

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

Anonymous
Not applicable

There are two custom variable: (I am hungarian, and i use hungarian expression.

In the picture you can se in red falg.

06. Pót alkatrész / Kopó alkatrész (P/K)

 In the picture you can se in blue falg.

09. Rajz A/H/Ö/K

 

When I realise these custom part value are wrong, I would like to modify from drowing. This rule rewrite these value from drowing to part or assembly. I dont't have to open the part.

I would like to use this rule to active sheet. When this rule work well, then I would like to upgrade to block rewrite. I designate more drawings and this rule upgrade these part or assembly with the same value.

 

 

0 Likes

laszlo.nagy
Contributor
Contributor
Accepted solution

Hello  Try this!

 

Helló próbáld meg ezt : )

 


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 Dim oDrawing As DrawingDocument oDrawing = ThisApplication.ActiveDocument Dim oView As DrawingView oView = oDrawing.ActiveSheet.DrawingViews.Item(1) Dim oModelDocument As Document oModelDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument Dim invUserDefProp As PropertySet Dim invProperty As Inventor.Property invUserDefProp = oModelDocument.PropertySets.Item("User Defined Properties") Try invProperty = invUserDefProp.Item("06. Pót alkatrész / Kopó alkatrész (P/K)") invProperty.Value = SparePart Catch invProperty =invUserDefProp.Add(SparePart,"06. Pót alkatrész / Kopó alkatrész (P/K)") End Try Try invProperty = invUserDefProp.Item("09. Rajz A/H/Ö/K") invProperty.Value = DWGType Catch invProperty =invUserDefProp.Add(DWGType,"09. Rajz A/H/Ö/K") End Try oModelDocument.Save
oModelDocument.Close

 

0 Likes