iLogic Expose "Thickness" to custom iProperty

iLogic Expose "Thickness" to custom iProperty

chrisw01a
Collaborator Collaborator
2,005 Views
6 Replies
Message 1 of 7

iLogic Expose "Thickness" to custom iProperty

chrisw01a
Collaborator
Collaborator

Ok.  I give up.

This should be simple.

 

Just need to flag the sheetmetal "Thickness" parameter for export, then create a custom iProp called "Thickness" and assign its value to sheetmetal Thickness.

 

What am I doing wrong here?

 

Keep getting this message :

 

Error in rule: ASY Total Part QTY, in document: 82387-070.iam

Public member 'Parameter' on type 'SheetMetalComponentDefinition' not found.

 

'Set a reference to the primary ComponentDefinition of the row
	Dim oCompDef As ComponentDefinition = oBOMRowPO.ComponentDefinitions.Item(1)
	
	'Check if the component is supressed
	'If oCompDef.Suppressed = False Then
	
	
		'get the full filename associated to the component in the row. ex: c:\temp\part1.ipt
		Dim CompFullDocumentName As String = oCompDef.Document.FullDocumentName
		Dim CompFileNameOnly As String
		'get the location of the last backslash
		Dim index As Integer = CompFullDocumentName.lastindexof("\")
		'get the filename only from the full filename
		CompFileNameOnly = CompFullDocumentName.substring(index+1)
		'MessageBox.Show(CompFileNameOnly)
		'get the Qty value in the current row
		Dim Qty As String = oBOMRowPO.TotalQuantity
		'check to see if the component is a library part, cc part or read only.
		Dim IsLibCCReadonly As Boolean = LibCCReadonlyChecker(CompFullDocumentName)
		
			'if the file is NOT a library part, cc part or read only.
			If IsLibCCReadonly = False Then
			'set following custom iproperty to equal the QTY from the row
			iProperties.Value(CompFileNameOnly, "Custom", "TotalPartQty") = Qty
			
				' Look at the sheet metal parts only
				'If oDoc.DocumentSubType.DocumentSubTypeID <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For
				Dim oParam As Inventor.Parameter = oCompDef.Parameters.Item("Thickness")
				If oParam IsNot Nothing Then
				'Flag to export
				oParam.ExposedAsProperty = True	

'Problem happens is HERE ....... iProperties.Value(CompFileNameOnly, "Custom", "Thickness") = oCompDef.Parameter("Thickness")
End If

 

Thank you guys

 

 

0 Likes
Accepted solutions (1)
2,006 Views
6 Replies
Replies (6)
Message 2 of 7

HermJan.Otterman
Advisor
Advisor

Hello Chris,

 

first, for the future, turn on the checkbox in your sheetmetal template.......

 

 

Here is some (VB.net) code... (What are you using?)

 

Private Sub TurnOnThicknessExport()

Dim oAssyDoc As AssemblyDocument = _inventorApplication.ActiveDocument

Dim oDoc As Inventor.Document

For Each oDoc In oAssyDoc.AllReferencedDocuments

If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then

Dim oPartDoc As PartDocument = TryCast(oDoc, PartDocument)

If oPartDoc.ComponentDefinition.Type = ObjectTypeEnum.kSheetMetalComponentDefinitionObject Then

Dim oParam As Inventor.Parameter = GetParameterByName(oPartDoc, "Thickness")

oParam.ExposedAsProperty = True

End If

End If

Next

End Sub

 

 

 

Private Function GetParameterByName(ByVal oPartDoc As Inventor.PartDocument, ByVal ParmName As String) As Inventor.Parameter

Dim oParam As Inventor.Parameter = Nothing

Dim oParamFound As Boolean = False

For Each oParam In oPartDoc.ComponentDefinition.Parameters

If oParam.Name = ParmName Then

oParamFound = True

Exit For

End If

Next

If oParamFound = False Then oParam = Nothing

Return oParam

End Function

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 7

b_sharanraj
Advocate
Advocate

I didn't execute you code still i see this should be corrected as

 

'Problem happens is HERE .......			
iProperties.Value(CompFileNameOnly, "Custom", "Thickness") = oCompDef.Parameters.Item("Thickness").Value

Regards

B.Sharan Raj

Message 4 of 7

HermJan.Otterman
Advisor
Advisor
Accepted solution

maybe you should execute the code....!?

if you check the export check box, there will be automatically a property with the name and value.

so I don't see what you code is doing...

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 5 of 7

chrisw01a
Collaborator
Collaborator

Lol.  I was trying to overcomplicate it.

Thank you.

 

Chris

0 Likes
Message 6 of 7

mikejones
Collaborator
Collaborator

Hi @HermJan.Otterman

 

Is there any chance of writing that in iLogic  instead of VBA?

 

Mike

Autodesk Certified Professional
0 Likes
Message 7 of 7

HermJan.Otterman
Advisor
Advisor

Hello Mike,

 

just copy paste all code in an iLogic rule,  then only change the first two lines:

 

Private Sub Main()

Dim oAssyDoc As AssemblyDocument = ThisDoc.Document

the first sub sould be called "Main"

then, to get the document, use the iLogic code for this: ThisDoc.Document

now it should work

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan