iLogic, API or VBA to access offset values for attached point clouds.

iLogic, API or VBA to access offset values for attached point clouds.

arron.craig
Collaborator Collaborator
162 Views
1 Reply
Message 1 of 2

iLogic, API or VBA to access offset values for attached point clouds.

arron.craig
Collaborator
Collaborator

I'm wanting to retrieve the offset and rotation values for attached point cloud files within parts and ideally then delete the attachment but cannot find any documentation covering these values.

My goal is to store these values in an annotation in the part file, export them to a text file, delete the .rcs or .rcp from the part and then archive that text file with the original scan to cold storage before checking the part back into the vault. 


arroncraig_0-1747602201382.png

 






0 Likes
Accepted solutions (1)
163 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

Hi @arron.craig.  I do not really use PointClounds much myself, but may be able to help some with come code to get you started towards your goal.  Below is some code I just typed within an iLogic rule, designed to be used on a part.  Right now it will only 'record/write' the PointCloud's name, source file, units factor, and offset in X, Y, & Z.  You may be able to develop it further to get the 'rotation' data you are looking for from the transformation Matrix we get from the PointCloud.  There is no simple, direct property for retrieving that data, so some 'interpretation' may need to be involved.  Plus, I have no idea how you need all this information formatted, and have no use for any of it myself.  There is a direct method for deleting the PointClound though (PointCloud.Delete).  I did not include that at this point either, because I know more development will be needed in the 'report' portion of this before you will want to be deleting them.

Sub Main
	Dim oPDoc As PartDocument = Nothing
	'used if 'receiving' the Document from a 'RunRule' method with 'arguments'
	'lets us use this rule like a Sub routine with 'input parameter(s)'
	If RuleArguments.Exists("Document") Then
		oPDoc = TryCast(RuleArguments.Value("Document"), Inventor.PartDocument)
	Else
		'used if no Document 'received'
		oPDoc = TryCast(ThisDoc.Document, Inventor.PartDocument)
	End If
	If oPDoc Is Nothing Then Return
	Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
	Dim oPtClouds As PointClouds = oPDef.PointClouds
	If oPtClouds.Count = 0 Then Exit Sub
	Dim oReport As New System.Text.StringBuilder()
	oReport.AppendLine("PointClouds Report:")
	For Each oPtCloud As PointCloud In oPtClouds
		oReport.AppendLine("PointCloud Name = " & oPtCloud.Name)
		oReport.AppendLine("SourceFullFileName = " & oPtCloud.SourceFullFileName)
		oReport.AppendLine("UnitsFactor = " & oPtCloud.UnitsFactor.ToString())
		Dim oTransform As Inventor.Matrix = oPtCloud.Transform
		Dim oOffset As Inventor.Vector = oTransform.Translation
		oReport.AppendLine("Offset X = " & oOffset.X.ToString())
		oReport.AppendLine("Offset Y = " & oOffset.Y.ToString())
		oReport.AppendLine("Offset Z = " & oOffset.Z.ToString())
		oReport.AppendLine()
	Next
	WriteStringToTextFile(oReport.ToString(), "C:\Temp\PointClouds Report.txt", True)
End Sub

Sub WriteStringToTextFile(sStringToWrite As String, sTextFile As String, bLaunch As Boolean)
	If sStringToWrite Is Nothing OrElse sStringToWrite = String.Empty Then Exit Sub
	If sTextFile Is Nothing OrElse sTextFile = String.Empty Then Exit Sub
	If System.IO.File.Exists(sTextFile) Then
		System.IO.File.WriteAllText(sTextFile, sStringToWrite)
	Else 'file does not already exist
		Using oSW As System.IO.StreamWriter = System.IO.File.CreateText(sTextFile)
			oSW.Write(sStringToWrite)
			oSW.Close()
		End Using
	End If
	If bLaunch = True Then
		Process.Start(sTextFile)
	End If
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)