Hi,
I am aware that I am responding to an old thread here that describes a several year old problem to which there is an Idea-Station thread to bring the feature back.
However, I have not been able to find a real solution yet.
So I wrote a few small iLogic scripts for our company that provide some kind of workaround.
The scripts move elements in assemblies based on the 3 axes. 3D annotations are taken along.
The solution is not as comfortable as the Autodesk function until 2017 but still helps us.
The rule works only without constraints or connections, so you should suppress them beforehand or export as Step and import again to get rid off alls constraints.
Maybe someone can use the code for himself or modify and develop it further.
Script 1:
The code performs a random offset of all components in an assembly. The offset is entered by the user and randomly generated for each axis.
'Original Code by posted at https://clintbrown.co.uk/undo
'Based on Brian Ekins Blog post: https://modthemachine.typepad.com/my_weblog/2009/03/combining-multiple-actions-into-a-single-undo.html
oDoc = ThisDoc.Document
Dim CADTIP As String = "@ClintBrown3D"
oNamer = "Explosionsdarstellung - Alle Bauteile"
Dim UNDO As Transaction
UNDO = ThisApplication.TransactionManager.StartTransaction(oDoc, oNamer)
'Your iLogic code goes in here:
'-------------------------------------------------------------------------------------------------------------------------------------
' Get the active assembly document
Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument
' Prompt the user for the displacement value
Dim displacement As Double = InputBox("Versatz-Abstand (in mm) eingeben:", "Versatz-Abstand")
' Create a random number generator
Dim random As New Random()
' Loop through all component occurrences in the assembly
For Each occurrence As ComponentOccurrence In asmDoc.ComponentDefinition.Occurrences
Dim transform As Matrix = occurrence.Transformation
' Generate random displacement values for each axis
Dim randomDisplacementX As Double = random.NextDouble() * displacement
Dim randomDisplacementY As Double = random.NextDouble() * displacement
Dim randomDisplacementZ As Double = random.NextDouble() * displacement
' Update the translation values in the transformation matrix
transform.Cell(1, 4) = transform.Cell(1, 4) + randomDisplacementX
transform.Cell(2, 4) = transform.Cell(2, 4) + randomDisplacementY
transform.Cell(3, 4) = transform.Cell(3, 4) + randomDisplacementZ
occurrence.Transformation = transform
Next
'-------------------------------------------------------------------------------------------------------------------------------------
UNDO.End
Script 2:
The code performs a random offset of all first level elements in an assembly. The offset is entered by the user and randomly generated for each axis.
'Original Code by posted at https://clintbrown.co.uk/undo
'Based on Brian Ekins Blog post: https://modthemachine.typepad.com/my_weblog/2009/03/combining-multiple-actions-into-a-single-undo.html
oDoc = ThisDoc.Document
Dim CADTIP As String = "@ClintBrown3D"
oNamer = "Explosionsdarstellung - Erste Ebene"
Dim UNDO As Transaction
UNDO = ThisApplication.TransactionManager.StartTransaction(oDoc, oNamer)
'Your iLogic code goes in here:
'-------------------------------------------------------------------------------------------------------------------------------------
' Get the active assembly document
Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument
' Prompt the user for the displacement value
Dim displacement As Double = CDbl(InputBox("Versatz-Abstand (in mm) eingeben:", "Versatz-Abstand"))
' Create a random number generator
Dim random As New Random()
' Loop through all component occurrences in the assembly
For Each occurrence As ComponentOccurrence In asmDoc.ComponentDefinition.Occurrences
' Check if the component occurrence is a top-level component or subassembly
If occurrence.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
Dim transform As Matrix = occurrence.Transformation
' Generate random displacement values for each axis
Dim randomDisplacementX As Double = random.NextDouble() * displacement
Dim randomDisplacementY As Double = random.NextDouble() * displacement
Dim randomDisplacementZ As Double = random.NextDouble() * displacement
' Update the translation values in the transformation matrix
transform.Cell(1, 4) = transform.Cell(1, 4) + randomDisplacementX
transform.Cell(2, 4) = transform.Cell(2, 4) + randomDisplacementY
transform.Cell(3, 4) = transform.Cell(3, 4) + randomDisplacementZ
occurrence.Transformation = transform
End If
Next
'-------------------------------------------------------------------------------------------------------------------------------------
UNDO.End
Script 3:
The code performs a random offset of all user-selected elements in an assembly. The offset is entered by the user and randomly generated for each axis.
'Original Code by posted at https://clintbrown.co.uk/undo
'Based on Brian Ekins Blog post: https://modthemachine.typepad.com/my_weblog/2009/03/combining-multiple-actions-into-a-single-undo.html
oDoc = ThisDoc.Document
Dim CADTIP As String = "@ClintBrown3D"
oNamer = "Explosionsdarstellung - Mit Auswahl"
Dim UNDO As Transaction
UNDO = ThisApplication.TransactionManager.StartTransaction(oDoc, oNamer)
'Your iLogic code goes in here:
'-------------------------------------------------------------------------------------------------------------------------------------
' Get the active assembly document
Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument
' Prompt the user to select the components to move
Dim comps As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection()
Dim selectSet As SelectSet = asmDoc.SelectSet
While True
' You can pick IAM or IPT from Model Browser or you can pick IPT in 3D Window
Dim comp As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Elemente auswählen. Drücke ESC zum Abschließen.")
If IsNothing(comp) Then Exit While
comps.Add(comp)
selectSet.Select(comp)
End While
' Prompt the user for the displacement value
Dim displacement As Double = CDbl(InputBox("Versatz-Abstand (in mm) eingeben:", "Versatz-Abstand"))
' Create a random number generator
Dim random As New Random()
' Loop through all selected component occurrences in the assembly
For Each occurrence As ComponentOccurrence In comps
Dim transform As Matrix = occurrence.Transformation
' Generate random displacement values for each axis
Dim randomDisplacementX As Double = random.NextDouble() * displacement
Dim randomDisplacementY As Double = random.NextDouble() * displacement
Dim randomDisplacementZ As Double = random.NextDouble() * displacement
' Update the translation values in the transformation matrix
transform.Cell(1, 4) = transform.Cell(1, 4) + randomDisplacementX
transform.Cell(2, 4) = transform.Cell(2, 4) + randomDisplacementY
transform.Cell(3, 4) = transform.Cell(3, 4) + randomDisplacementZ
occurrence.Transformation = transform
Next
'-------------------------------------------------------------------------------------------------------------------------------------
UNDO.End