Find T&P assemlby in parent.

Find T&P assemlby in parent.

ust25238
Contributor Contributor
430 Views
5 Replies
Message 1 of 6

Find T&P assemlby in parent.

ust25238
Contributor
Contributor

I am looking for a way to get the Tube and Pipe assembly  from the parent. I can't find how it is differentiated from a normal assembly.

Thanks .

0 Likes
431 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @ust25238.  This is something that is not very well documented and not used by a ton of folks, but you can use the Document.DocumentInterests property.  It represents every possible 'DocumentInterest' in the document.  This will indicate if any AddIn has any interest/influence on this document.  The DocumentInterests object has a HasInterest method which you could use, or you could use the ClientId property of an individual DocumentInterest within the collection to check if it is related to the Tube & Pipe AddIn.  To use them, you will need either the proper name of the AddIn ("Routed Systems: Tube & Pipe"), or its ClientId ("{4D39D5F1-0985-4783-AA5A-FC16C288418C}") to compare with.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

WCrihfield
Mentor
Mentor

Here is a bit of example code to get you started, in case you are not familiar with how to use what I mentioned.  It starts by getting the main assembly.  Then it gets the 'ClientId' of the Tube & Pipe AddIn (or you could just replace that bit of code with a single String type variable, and assign it the hard coded ClientId).  Then it loops through your components, checking if each one represents an assembly or not.  If not, it skips to next component.  When the component represents an assembly, it then gets the document that the component represents.  Then it checks that document's 'interests' to see if the Tube & Pipe AddIn has an 'interest' in it.  If it finds any, it shows a message with that components name in it.  You can change that part however you need to, because this is just an example of how to check that property.

oADoc = ThisAssembly.Document

Dim oClientID As String
For Each oAd As ApplicationAddIn In ThisApplication.ApplicationAddIns
	If oAd.DisplayName = "Routed Systems: Tube & Pipe" Then
		oClientID = oAd.ClientId
	End If
Next
If String.IsNullOrEmpty(oClientID) Then
	MsgBox("Did not find ClientId of Tube & Pipe AddIn.  Exiting rule.", , "")
	Exit Sub
End If

oOccs = oADoc.ComponentDefinition.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
	'if it's not an assembly, skip to next component
	If oOcc.DefinitionDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Continue For
	'get document
	Dim oOccDoc As Document = oOcc.ReferencedDocumentDescriptor.ReferencedDocument
	'check if Tube & Pipe has 'interest' in this document
	If oOccDoc.DocumentInterests.HasInterest(oClientID) Then
		'found it
		MsgBox("The Tube & Pipe AddIn has an 'interest' in the component named " & oOcc.Name, vbInformation, "iLogic")
	End If
Next

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

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 6

ust25238
Contributor
Contributor

Thanks for the quick reply. I have been so swamped I haven't been able to test yet. I will let you know how it works out. Thanks

0 Likes
Message 5 of 6

_dscholtes_
Advocate
Advocate

@WCrihfield 
Don't forget that a hose could also be a t&p assembly file 😉 You can use ".HasInterest("Piping Runs Environment")" to identify the master run assembly. At least, that works in my Inventor version (2018.3.10), together with "Piping Run Environment" (a run), "Piping Route Environment" (a route), "Piping Segment" (a pipe or hose) and "Piping Hose Environment" (a hose assembly).

Message 6 of 6

WCrihfield
Mentor
Mentor

Thanks @_dscholtes_.  I will take your word for it, because I don't really actively use that add-in, but have it available.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes