Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Derived part material and stock number

3 REPLIES 3
Reply
Message 1 of 4
jcloutierMQ36F
182 Views, 3 Replies

Derived part material and stock number

Hi,

is there a way to simply get material and stock number information in derived part from the base component?

Tags (1)
3 REPLIES 3
Message 2 of 4
WCrihfield
in reply to: jcloutierMQ36F

Hi @jcloutierMQ36F.  This can be a very confusing topic to ask questions about, so using correct terms/words and being as clear as possible is important.  I just want to make sure what the phrase "in derived part from the base component" means.

Scenario 1:  If you have a Part document open on your screen right now (the active document), and some 'other' part is derived into this active document, then are you wanting to be able to get the material and stock number from that 'other' part (the one that is derived into this part)?

Scenario 2:  If you have a Part document open on your screen right now (the active document), and this document is derived into some 'other' Part document, and you want to be able to get the material and stock number from the other Part document that this Part document is derived into?

 

Scenario 1 may be possible, but Scenario 2 would normally not be possible, but may be possible to achieve in certain special situations.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

The scenario 1 is exactly the case I wanted to explain, sorry for confusion.

I am wanting to get material, stock number and maby other innformation that are not parameters from derived part and use them into the active part.

In this specific case, I derived a part created by the frame generator into a new one that I want to modify. It works properly but I want the material and stock number to be updated if changes are done in the frame.

Message 4 of 4
WCrihfield
in reply to: jcloutierMQ36F

OK.  Since you want these things to stay updated when the original model changes, I do not believe this would be possible.  I may be able to access those things within the document that is being derived into this part, and I may be able to 'copy' their 'static' values into the active document, but I do not know of any way to include those things as part of the 'derive in' process/definition, so that they would stay 'linked'.  There is currently no built-in way to include iProperties or Material in the Derive Part definition.  When the original part was designed as sheet metal, and the part it is being derived into was also created as sheet metal, then there is an option to "Link Sheet Metal Styles", but I am not familiar enough with that setting to know if that will cause the very specific behavior of [if only the Material in original changes, that will automatically change only the material in the part that it is derived into].

WCrihfield_0-1712842903269.png 

WCrihfield_1-1712843020274.png 

WCrihfield_2-1712843037602.png

Here is some iLogic rule code you can play around with which shows hot to access a lot of those types of settings, just for future reference.

Sub Main
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
	'check to see if there are any Parts (DerivedPartComponents) derived into this document
	Dim oDPCs As DerivedPartComponents = oPDef.ReferenceComponents.DerivedPartComponents
	If oDPCs.Count = 0 Then
		Logger.Info("No DerivedPartComponents found in this PartDocument.")
		Return
	End If
	'<<< access the settings of the existing 'Derive Part' >>>
	'get just the first one (it is possible to have more than one)
	Dim oDPC As DerivedPartComponent = oDPCs.Item(1)
	'Log some of its direct settings
	Logger.Info("DerivedPartComponent HealthStatus = " & oDPC.HealthStatus.ToString)
	Logger.Info("DerivedPartComponent IsEmbedded = " & oDPC.IsEmbedded)
	Logger.Info("DerivedPartComponent LinkedToFile = " & oDPC.LinkedToFile)
	Logger.Info("DerivedPartComponent Name = " & oDPC.Name)
	Logger.Info("DerivedPartComponent SuppressLinkToFile = " & oDPC.SuppressLinkToFile)
	'get its 'Definition'
	Dim oDPDef As DerivedPartDefinition = oDPC.Definition
	'Log some of the Definition direct settings
	Logger.Info("Derive Style = " & oDPDef.DeriveStyle.ToString)
	Logger.Info("ActiveDesignViewRepresentation = " & oDPDef.ActiveDesignViewRepresentation)
	Logger.Info("IsAssociativeDesignView = " & oDPDef.IsAssociativeDesignView)
	Logger.Info("ActiveModelState = " & oDPDef.ActiveModelState)
	Logger.Info("LinkFaceColorFromSource = " & oDPDef.LinkFaceColorFromSource)
	Try : Logger.Info("LinkSheetMetalStyles = " & oDPDef.LinkSheetMetalStyles) : Catch : End Try
	Logger.Info("LinkSketchFormattingFromSource = " & oDPDef.LinkSketchFormattingFromSource)
	Logger.Info("ReducedMemoryMode = " & oDPDef.ReducedMemoryMode)
	Logger.Info("UseOrientedMinimumBoundingBox = " & oDPDef.UseOrientedMinimumBoundingBox)
	'find out which more specific type of DerivedPartDefinition this is, to access more specific stuff
	If TypeOf oDPDef Is DerivedPartCoordinateSystemDef Then
		Dim oDPCSDef As DerivedPartCoordinateSystemDef = oDPDef
		'access to more specific stuff

	ElseIf TypeOf oDPDef Is DerivedPartTransformDef Then
		Dim oDPTDef As DerivedPartTransformDef = oDPDef
		'access to more specific stuff
		
	ElseIf TypeOf oDPDef Is DerivedPartUniformScaleDef Then
		Dim oDPUSDef As DerivedPartUniformScaleDef = oDPDef
		'access to more specific stuff
		Logger.Info("ScaleFactor = " & oDPUSDef.ScaleFactor)
		
	End If
	'access the actual Document & File of the part derived into this document
	Dim sFDN As String = oDPC.ReferencedDocumentDescriptor.FullDocumentName
	Logger.Info("Derived-In FullDocumentName = " & sFDN)
	Dim oDerivedInPartFile As Inventor.File = oDPC.ReferencedDocumentDescriptor.ReferencedFileDescriptor.ReferencedFile
	Dim oDerivedInPartDoc As PartDocument = oDPC.ReferencedDocumentDescriptor.ReferencedDocument
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)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report