- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The following code will derive in multiple parts, whose filenames are specified under the "Specify parts to derived in" section. You could instead use a loop of InputBoxes to specify part filenames, or some other method -- I wasn't sure what to do because you didn't provide any details about how you want to specify the parts to be derived in.
Dim ruleTitle As String = "Derive Multiple" ' Get current part document (the "recipient" part) Dim partDoc As PartDocument = ThisDoc.Document ' Set reference to Derived Part Components manager for recipient part Dim derPartComps As DerivedPartComponents = partDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents ' Specify parts to derived in (the "source" parts) Dim sourcePartPaths As New List(Of String) sourcePartPaths.Add("C:\...\PartToDeriveIn.ipt") ' <-- Change to path of the part you want to derive in. sourcePartPaths.Add("...") ' <-- Repeat for each desired source part. If sourcePartPaths.Count > 0 Then ' Start transaction Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(partDoc, ruleTitle) ' Derive in each specified part Dim failedParts As New List(Of String) For Each sourcePartPath As String In sourcePartPaths If IO.File.Exists(sourcePartPath) Then Dim derivedPartDef As DerivedPartUniformScaleDef Try ' Create definition for derived part. derivedPartDef = derPartComps.CreateUniformScaleDef(sourcePartPath) Catch ex As Exception failedParts.Add("- '" & sourcePartPath & "': Error creating derive definition: '" & ex.Message & "'") Continue For End Try Try ' Set up the Derive. 'derivedPartDef.IncludeAll 'derivedPartDef.IncludeAllSolids = True Catch ex As Exception failedParts.Add("- '" & sourcePartPath & "': Error setting up derive: '" & ex.Message & "'") Continue For End Try Try ' Create Derive feature. derPartComps.Add(derivedPartDef) Catch ex As Exception failedParts.Add("- '" & sourcePartPath & "': Error creating derive feature: '" & ex.Message & "'") End Try Else failedParts.Add("- '" & sourcePartPath & "': File does not exist") End If Next If failedParts.Count = sourcePartPaths.Count Then trans.Abort Else trans.End End If If failedParts.Count > 0 Then MessageBox.Show("The following parts could not be Derived:" & vbCr & vbCr & String.Join(vbCr, failedParts), ruleTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If Else MessageBox.Show("Must provide at least one Part to derive in.", ruleTitle, MessageBoxButtons.OK, MessageBoxIcon.Information) End If
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks a lot for the reply.
This is the kind of rule I could never see in the forum.
It works great and is a great great help.
It brings all the entities in to the current document.
I do not like to bother you.
But, could you help me to get the following Derived Style dialog box. Thanks a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @RoyWickrama_RWEI, take a look at this page in the API documentation: DerivedPartDefinition Object. It covers how to set all of those configurations by applying them to the "derivedPartDef" object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for the guide line.
I will be able to get this around.
Will let you know the progress.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks DRoam.
I keep tailoring the rule to my needs. (rule attached here to)
Case - 1:
Currently, I have the following issue: i.e. the derived does not appear in the browser unless I close and reopen.
I appreciate receiving some help.
Case-2:
Still I could not figure out how to invoke the Derive Part Derive Style dialog box.