Local iLogic Rules in Mirrored Parts?

Local iLogic Rules in Mirrored Parts?

bbeilke
Advocate Advocate
1,248 Views
6 Replies
Message 1 of 7

Local iLogic Rules in Mirrored Parts?

bbeilke
Advocate
Advocate

I wasn't sure if this question was best asked in this forum or the general forum.  Please feel free to move this thread if necessary.

 

We have parts that contain local iLogic rules.  When making a mirror of these parts, we need the same iLogic rule(s) in the new mirrored parts.  We can obviously manually copy them from the original part and paste them in the new mirrored part.  But is there anyway to get Inventor to automatically transfer these rules to the mirrored part when it is created?  As an alternative, is there anyway to specify a template file for a mirrored part?  If so, the template could already have the required local iLogic rules.

 

Thanks.

Blane

0 Likes
1,249 Views
6 Replies
Replies (6)
Message 2 of 7

Andrii_Humeniuk
Advisor
Advisor

Hi @bbeilke . This rule must be used in an assembly, it can copy rules and events for mirror parts.

Sub main()
	Dim oDoc As Document = ThisDoc.Document
	If Not TypeOf oDoc Is AssemblyDocument Then Exit Sub
	Dim oAsmDoc As AssemblyDocument = oDoc
	Dim oRefDocs As DocumentsEnumerator = oAsmDoc.AllReferencedDocuments
	If oRefDocs.Count = 0 Then Exit Sub
	Dim oDocs As Documents = ThisApplication.Documents
	Dim oST As Transaction = ThisApplication.TransactionManager.StartTransaction(oAsmDoc, "CopyRules")
	Dim oPBar As Inventor.ProgressBar = ThisApplication.CreateProgressBar(False, oRefDocs.Count, "Copy ryles...")
	Dim i As Integer = 1
	oPBar.Message = "Loading..."
	For Each oRefDoc As Document In oRefDocs
		oPBar.Message = "Copy ryles in document. Progress " & i & " of " & oAsmDoc.AllReferencedDocuments.Count & "."
		If TypeOf oRefDoc Is PartDocument AndAlso oRefDoc.IsModifiable Then
			Dim oPartDoc As PartDocument = oRefDoc
			Dim oDrcdComp As DerivedPartComponents = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents
			If oDrcdComp.Count = 0 Then Continue For
			If Not oDrcdComp.Item(1).Definition.Mirror Then Continue For
			Dim oDrcdDoc As Document = oDrcdComp.Item(1).ReferencedDocumentDescriptor.ReferencedDocument
			Call CopyRules(oDrcdDoc, oPartDoc)
			Call CopyEventsPropSet(oDrcdDoc, oPartDoc)
			oPartDoc.Save()
		End If
		oPBar.UpdateProgress()
		i += 1
	Next
	oPBar.Close()
	oST.End()
End Sub

Private Function CopyRules(CopyFrom As Document, CopyTo As Document)
	Try
		For Each oRule As iLogicRule In iLogicVb.Automation.Rules(CopyFrom)
			Dim oCopy As iLogicRule = iLogicVb.Automation.AddRule(CopyTo, oRule.Name, "")
			oCopy.Text = oRule.Text
		Next
	Catch : End Try
End Function

Private Function CopyEventsPropSet(CopyFrom As Document, CopyTo As Document)
	Dim oPropSet As Inventor.PropertySet = CopyFrom.PropertySets("{2C540830-0723-455E-A8E2-891722EB4C3E}")
	Try
		CopyTo.PropertySets("{2C540830-0723-455E-A8E2-891722EB4C3E}").Delete()
	Catch
	End Try
	Dim newPropSet As Inventor.PropertySet = CopyTo.PropertySets.Add("_iLogicEventsRules", "{2C540830-0723-455E-A8E2-891722EB4C3E}")
	For Each prop As Inventor.Property In oPropSet
		newPropSet.Add(prop.Value, prop.Name, prop.PropId)
	Next
End Function

 

 

 

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 7

drafter_sby2
Contributor
Contributor

Can It Be on default Program on Inventor?  So. when People Mirroring part it can be copy rule as Default?

0 Likes
Message 4 of 7

Andrii_Humeniuk
Advisor
Advisor

Hi @drafter_sby2 .

Thank you for your feedback.

I created the idea on the forum. I hope you will cast your vote, it will help attract the attention of the developer.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 5 of 7

WCrihfield
Mentor
Mentor

Hi @Andrii_Humeniuk.  Nice routine.  But after reading through it, I was just curious about Line 18 of that code example.  I can not find that final ".Mirror" member anywhere in any of the official Inventor API documentation.  I was expecting that to be a Property of the DerivedPartDefinition object (or one of its derived object types), with a Boolean value Type, but could not find it.  Is that a 'hidden' property?  I assume by how it is being used there that it is supposed to signify that the DerivedPartDefinition was created by a MirrorFeature, is that correct?  If it was hidden, then how did you discover it, and how did you find out what it was used for?  Or maybe they were available in older versions of Inventor, but were hidden in newer versions?

 

Below are links to the Inventor 2025 online help documentation for those Inventor API object types:

DerivedPartDefinition (base Type)

DerivedPartCoordinateSystemDef (Type derived from DerivedPartDefinition Type)

DerivedPartTransformDef (Type derived from DerivedPartDefinition Type)

DerivedPartUniformScaleDef (Type derived from DerivedPartDefinition Type)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 7

Andrii_Humeniuk
Advisor
Advisor

Hi @WCrihfield .

Yes, you are right, it is a hidden method. I found out about him from a google search.​​​​😁
Not exactly sure where exactly I found this method, because I wrote the solution a year ago. But again searching above me here is this link.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 7 of 7

Yijiang.Cai
Autodesk
Autodesk

This is a good enhancement request, and has been tracked as INVGEN-86829. In Inventor 2026, we provided the associative mirror, which makes the target component associative with the source. Please have a try! As to this enhancement request, I suppose you talk more about the legacy mirror.

There is another solution that you could use external rule, and it could be applied to all the documents.

Many thanks!

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: [email protected]
0 Likes