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

Rule for measurements

Hello everyone,

 

I'm currently working on a rule and I have one slight problem. The problem is that this rule returns the measurements from the assembly, I want the measurements from the referenced documents.

 

Sub Main()
	Dim StartTime As DateTime
	Dim aElapsedTime As TimeSpan
	StartTime = Now
	Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments
	aPropParNum = oAsmDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
	aFileNameWithoutExt = IO.Path.GetFileNameWithoutExtension(oAsmDoc.FullDocumentName)
	
	For Each oRefDoc In oRefDocs
	bPropParNum = oRefDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
	bFileNameWithoutExt = IO.Path.GetFileNameWithoutExtension(oRefDoc.FullDocumentName)
	bFullpath = IO.Path.GetFullPath(oRefDoc.FullDocumentName)
	bFileName = IO.Path.GetFileName(oRefDoc.FullDocumentName)
	If oRefDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then
	If InStr(bFileNameWithoutExt, "koker", CompareMethod.Text) = 1 Then
	
	ThisApplication.Documents.Open(bFullpath, True)
	InventorVb.DocumentUpdate()
	aDocument = ThisApplication.ActiveDocument
	iProperties.Value(aDocument, "Custom", "aMeasure") = Measure.ExtentsHeight
	iProperties.Value(aDocument, "Custom", "bMeasure") = Measure.ExtentsWidth
	iProperties.Value(aDocument, "Custom", "cMeasure") = Measure.ExtentsLength
	If aDocument.Open Then aDocument.Close(True)
	
	End If
	End If
	Next
	aElapsedTime = Now().Subtract(StartTime)
	bElapsedTime = aElapsedTime.TotalSeconds
	oWrite = System.IO.File.CreateText("X:\01 productie\25 Werkvoorbereiding\07 Zaaglijsten\" & aFileNameWithoutExt & ".txt")
	oWrite.WriteLine(aFileNameWithoutExt & vbCrLf & DateString & " " & Timestring)
	oWrite.WriteLine("All data was collected in " & Round(bElapsedTime, 2) & "s" & vbCrLf & "")
	oWrite.WriteLine("Tubes:" & vbCrLf & oListB)
	oWrite.Close()
End Sub

 

 

Thank you, Stan Mertens