Transfer Parameter Value to iProperty

Transfer Parameter Value to iProperty

cadman777
Advisor Advisor
541 Views
2 Replies
Message 1 of 3

Transfer Parameter Value to iProperty

cadman777
Advisor
Advisor

Hey Guys,

I'm trying to transfer the sheetmetal 'Thickness' Parameter to the "Manager" Inventor iProperty but can't figure out what I don't know on what code to add. Any help is appreciated. Here's the Code I'm trying to use:

 

' Open assembly file and add assembly filename to 'Authority' iProperty if it doesn't exist

' Open and activate assembly file
Dim openDoc As Document = ThisDoc.Document

' Get the assembly filename
Dim oAssyFileName As String = ThisDoc.FileName(False)
'MessageBox.Show(oAssyFileName, "oAssyFileName")

' Access all part files in assembly
Dim docFile As Document
If openDoc.DocumentType = kAssemblyDocumentObject Then    
	For Each docFile In openDoc.AllReferencedDocuments
		
		'Check for sheetmetal document type
		'If openDoc = kSheetmetalDocumentObject Then
		
		' Get the part's sheetmetal "Thickness" Parameter
		Dim oThickness As Double
		On Error Resume Next
		oThickness = Round((docFile.ComponentDefinition.Parameters.Item("Thickness").Value * .3937), 3)
			'MessageBox.Show(oThickness, "oThickness")
		
		' Change the value of 'Manager' iProperty to 'Thickness' Parameter
		docFile.PopertySets.Item("Inventor Document Summary Information").Item("Manager").Value = oThickness
		
		' Change the value of 'Authority' iProperty to 'oAssyFileName' iProperty
		docFile.PropertySets.Item("Design Tracking Properties").Item("Authority").Value = oAssyFileName
		
		'End If
	Next
	Else
		MessageBox.Show("You must have a valid Assembly document open before using this code!", _
						"File Type Mismatch!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If

 

This is the line that's giving me trouble:

' Change the value of 'Manager' iProperty to 'Thickness' Parameter
    docFile.PopertySets.Item("Inventor Document Summary Information").Item("Manager").Value = oThickness

What I don't understand is WHY it works with the assembly's FileName but not with the Parameter? I tried at least a dozen things to see if it was my error, such as mis-spelled words, converting a Double to Text, different ways to access the iProperty, etc. But STILL, I don't know rabbithole I need to go down to ensure I'm tapping into the values I need and correctly passing them on to where they need to go.

 

Also, will someone please tell me how to colorize the words when I post them in this snipped area?

 

Thanx for the help!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Accepted solutions (1)
542 Views
2 Replies
Replies (2)
Message 2 of 3

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

First, there are no PopertySets, only PropertySets. 😉

Are you really sure you want to abuse the standard iProps with values they are not planned for? Why don't you create user defined properties for your needs?

 

' Open assembly file and add assembly filename to 'Authority' iProperty if it doesn't exist

Dim openDoc As Document = ThisDoc.Document
Dim oAssyFileName As String = ThisDoc.FileName(False)
'MessageBox.Show(oAssyFileName, "oAssyFileName")

Dim docFile As Document
Dim partfile As PartDocument
If openDoc.DocumentType = kAssemblyDocumentObject Then    
	For Each docFile In openDoc.AllReferencedDocuments
		If docFile.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
			partfile = DirectCast(docFile, PartDocument)
			
			'Check for sheetmetal document type
			If partfile.SubType=  "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
				Dim oSheetMetalCompDef As SheetMetalComponentDefinition = partfile.ComponentDefinition
				
				' Get the part's sheetmetal "Thickness" Parameter
				Dim oThickness As Double
				'On Error Resume Next
				oThickness = Round(oSheetMetalCompDef.Thickness.ModelValue  * .3937, 3)
				'oThickness = Round((docFile.ComponentDefinition.Parameters.Item("Thickness").Value * .3937), 3)
				'MessageBox.Show(oThickness & " oThickness")
				
				' Change the value of 'Manager' iProperty to 'Thickness' Parameter
				partfile.PropertySets.Item("Inventor Document Summary Information").Item("Manager").Value = oThickness
				
				' Change the value of 'Authority' iProperty to 'oAssyFileName' iProperty
				partfile.PropertySets.Item("Design Tracking Properties").Item("Authority").Value = oAssyFileName
			
			End If
			partfile=Nothing
		End If
	Next
Else
	MessageBox.Show("You must have a valid Assembly document open before using this code!", _
					"File Type Mismatch!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 3

cadman777
Advisor
Advisor

LOL! Spelling will get you EVERY time!

That fixed it for me.

Blind as a bat from 'slow death by computer'!

Much obliged!

 

And 'yes' I want to 'play dirty'.

It suits my simple work-flow using a drawing template file.

I would do it your way IF I could find a way to LINK Parameters between files, or if I could create drawing view labels that have LINKED iProperties and linked Parameters. But all the code I've seen in here deletes all the template links in the drawing views and uses plain text. Doesn't that defeat the purpose for using templates? You may as well just use a blank idw file and iLogic/VBA/VB.Net the whole thing like I used to do with AutoLISP in AutoCAD back in the olden days of 2D madness.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes