Copy assembly components with constraints

Copy assembly components with constraints

sschulteH6WZ3
Advocate Advocate
8,683 Views
22 Replies
Message 1 of 23

Copy assembly components with constraints

sschulteH6WZ3
Advocate
Advocate

Hi all I am trying to copy hardware (bushings) in an assembly and keep the constraints from the first instance. In SW it was copy with mates and very easy very fast to do so. Going by Inventor help page titled "copy assembly components" this should do the same thing. However I can not make it work. Does any one know how to do it? Please don't suggest I just pattern it as very few things in life have a set repeating pattern all in the same plane.

Accepted solutions (1)
8,684 Views
22 Replies
Replies (22)
Message 2 of 23

MechMachineMan
Advisor
Advisor
Accepted solution

Inventor only has constraint retention between parts in the select set. If you are copying and pasting a group of parts, there is no was to retain the constrains to other object. 

 

Logistically, if you were do to this, it copying would place the parts in the exact same location anyways because how does it know what is the intended free DOF unless you have the model intentionally under constrained?

 

Not saying the functionality isn't possible, but it's not out of the box. I have created my own macro to accomplish such a thing.

 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 23

sschulteH6WZ3
Advocate
Advocate

So in this case Inventor is far behind the times. Their main competitor has had copy with mates for years. It is very possible since the other software does it very well.

Message 4 of 23

MikeKovacik4928
Advisor
Advisor

You can assign imates to objects so that they automatically constrain to each other,

thus even though your part loses it constraint to a part not in the selection set,

it can automatically constrain to another part with a suitable imate

I still haven't used them yet, so can't comment on how good or user friengly they are, but am planning to start very soon.

 

I am not familiar with and have never used Solidworks, so don't know how it compares.

 

Michael Kovacik

Draughting/Designing (Manufacturing) (31 yrs)
Cad (28 yrs)
AutoCAD 2d & 3d (16 yrs)
Inventor (4 yrs)
Autocad and Inventor Simutaneously (4 years)

Autodesk Product Design Suite Ultimate 2018
Autocad 2018, Inventor Pro 2018
Johannesburg, South Africa

0 Likes
Message 5 of 23

BP-OZ
Enthusiast
Enthusiast

I find this one of the most frustrating things with Inventor. Having to fully constrain copied parts. Parts are initially constrained with 2 or 3 constraints. When copying, I think there should be an option to keep or modify those constraints.

Unfortunately, I don't know anything about macros etc, but surely if others can do it, Autodesk can do it.

it is very frustrating.

Message 6 of 23

sschulteH6WZ3
Advocate
Advocate

Yea SW has been able to do it at least 5 or 6 years now and I think longer. I don't understand why these people are so far behind. Perhaps there is patent issues involved.

Message 7 of 23

sschulteH6WZ3
Advocate
Advocate

Their main competitor figured it out years ago and its out of the box.

Message 8 of 23

johnsonshiue
Community Manager
Community Manager

Hi Guys,

 

I agree, if a competitor can do that, Inventor should be able to match the behavior. It is a matter of prioritizing and planning.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 9 of 23

Anonymous
Not applicable

This is one EXTREMELY weak point with Inventor.  I used Solid Edge in the very early 2000's, it had a very fast way to insert multiple instances of a part, and have used SolidWorks 2017 and Inventor 2017 for the past year.  SW does have "copy with Mates" that I wish Inventor had comparably.  I looked at iMates in the past, but that is a poor work around when you have thousands of parts already in the system.  No one is going to go through the pain of adding iMates to all those parts.  Solid edge and Solidworks do not need that, why does Inventor?

 

Ideally you should insert a part, and then be able to click on every position you need it.

 

Also, I wish Inventor would not need you to click "accept" every time you insert a constraint!  If I make a mistake, it is easy to go back a step and fix it.  Inventor seems to assume you are always going to do it wrong and makes you click accept every time.  I do it right 99% of the time, do not need "Nanny" to question me every time.  8>(

Message 10 of 23

MikeKovacik4928
Advisor
Advisor

Hi evart

 

I have been an Inventor User for 8 years. I must admit I have never used anything else besides Inventor, so I have  never been able to compare.

It has been an issue with me too, see my previous post about attempting to use Imates to solve the issue. That never happened, after looking at

it, it was too much of a tedious and time consuming work around for existing parts, just like you said.

I do have a 30 day trial version of Solidworks which expires in 18 days, so will definitely have a look to see how they get around it!

 

I still wish that Inventor would bring in something comparible, as even though I have lapsed my personal subscription for Autodesk Product

Design Suite 2018, I will continue working on Inventor 2018 at home, and at work will continue working on the latest Inventor, which is still on subscription.

 

Michael Kovacik
2d & 3d Autocad and Inventor designer/draughtsman
.
Draughting/Designing (Manufacturing) (31 yrs)
-Drawing Board (3 yrs)
--Cad (28 yrs)
---Cadkey (4 yrs)
---AutoCAD 2d & 3d (16 yrs)
---Inventor (4 yrs)
---Autocad and Inventor Simultaneously (4 years)
---(and recently Autocad/Inventor Customisation)
.
Autodesk Product Design Suite Ultimate 2018
Autocad 2018, Inventor Pro 2018
(personal licensed copy)
.
Johannesburg, South Africa
.
(Impossible only means you haven't
found the solution yet)

 

 

 

Message 11 of 23

Anonymous
Not applicable

I have used CAD for over 35 years, multiple systems, 2D and 3D.  SolidEdge was my first 3D modeler, loved it.  Moved to new company, had to learn Inventor.  I have used Inventor for about 5 years now. A year ago, company took on a project using SolidWorks, so learned that one too.

All three, SolidEdge, Inventor, and Solidworks each have their good and bad points, hard to choose between them which is "best".  Some depends on work being done, and how much work is done beyond just mechanical 3D design.  I have a pretty large list of things I think Inventor does better than SolidWorks, but recently got back to Inventor from using Solidworks almost exclusively for over a year.  Now I have a shorter list of things SolidWorks does better than Inventor.  One of those is placing multiple instances of a part into an assembly!  Inventor really is years behind on that.

 

The new Inventor "Joint" feature is really good though, far quicker to place circular items such as screws, bushings, bearings, etc.. SolidWorks does not do that very well, their "Alt-Pick" function works sometimes, but not all the time. Frustrating to use it wondering if it will work, when much of the time it does not.

 

I sure wish there was a "SolidInventor", combining the better points of all three into one package!  I have to say right now that there is no "best" one, having used all three.  SolidWorks is the most popular, but that only means they had the better marketing, not that they are actually better.  Same as when many years ago AutoCad was the most popular, when there were better 2D CAD packages out there.  I know from long experience back then that Anvil 1000MD ran circles around Autocad, easier, faster, and never broke! I still think Anvil 1000 was the best mechanical 2D CAD ever.  Never used Anvil 3D, not sure how it compared.

 

Of course there was AutoDesk Mechanical! Probably the worst ever!  I worked for one company that purchased 15 seats of that, after a couple years we replaced them with SolidEdge, threw the Autodesk Mechanical in the trash. That was an expensive hard lesson learned.

0 Likes
Message 12 of 23

MikeKovacik4928
Advisor
Advisor

After having messed around with the solidworks 30 day trial version in the evenings for a few weeks,

I see, in principle it is exactly the same as Inventor. The interface, commands and methods of operating

are indeed quite different. It would take me a good 2 months to get up some sort of speed on it.

 

If I was a contractor working with my own software, and charging out on an hourly rate, that would cost me big bucks!!

 

I will not change, and will stick with my Inventor, unless future work changes force me to do otherwise.

 

I will however continue to investigate Solidworks, just out of curiosity, until my 30 day trial is up on 1 March

 

Thanks evart for the useful feedback on your 35 years of CAD experience.

I totally agree with you that no one 3d solid parametric modelling software is that much better than any other,

and that it is just a matter of how you are trained, what best pracitces you use, and how you interact with other

users to find better solutions.

 

Mike

 

0 Likes
Message 13 of 23

MechMachineMan
Advisor
Advisor

Here is a quick little bonus macro for you all.

 

It is not flawless - sometimes patterns and work features mess it up, BUT it will duplicate the selection of parts and the constraints between those parts and the assembly the rule is ran from. It places the parts directly over top of the previous one for this reason, so if you want to quickly change it, it is recommended that you leave 1 DOF free.

 

Private oNewlyInsertedColl As Collection
Private oOriginalItemColl As Collection

Public Sub DupeSelectionWithConstraints()
    If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MsgBox ("Rule not valid for non-assembly files!"): Exit Sub
    
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSS As SelectSet
    Set oSS = oDoc.SelectSet
    
    If oSS.Count < 1 Then MsgBox ("Rule Requires a Select Set!"): Exit Sub
    
    Call DuplicateSS(oDoc, oSS)
End Sub


Private Sub DuplicateSS(oParentDoc As Document, oSS As SelectSet)
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry
    
    Set oPasteMatrix = oTG.CreateMatrix()
    
    Set oOriginalItemColl = New Collection
    Set oNewlyInsertedColl = New Collection
    
    For Each oItem In oSS
        Set oPasteMatrix = oItem.Transformation
        Set oNewOcc = oParentDoc.ComponentDefinition.Occurrences.Add(oItem.Definition.Document.FullDocumentName, oPasteMatrix)
        oOriginalItemColl.Add oItem
        oNewlyInsertedColl.Add oNewOcc
    Next
    
    Dim oTestoOcc1 As Object
    Dim oTestoOcc2 As Object
    
    Dim oOcc1 As ComponentOccurrence
    Dim oOcc2 As ComponentOccurrence
    
    Dim oEntityOne As Object
    Dim oEntityTwo As Object
    
    For Each oConstraint In oParentDoc.ComponentDefinition.Constraints
    'Grab entities for new constraint to create
            Set oTestoOcc1 = GrabObjectFromColl(oOriginalItemColl, oConstraint.OccurrenceOne)
            Set oTestoOcc2 = GrabObjectFromColl(oOriginalItemColl, oConstraint.OccurrenceTwo)
            
            If oTestoOcc1 Is Nothing And oTestoOcc2 Is Nothing Then GoTo NextConstraint
            
            If oTestoOcc1 Is Nothing Then
                Set oEntityOne = oConstraint.EntityOne
            Else
                For Each oPossibleOcc In oNewlyInsertedColl
                    If oPossibleOcc.Definition Is oTestoOcc1.Definition Then
                        Set oOcc1 = oPossibleOcc
                    End If
                Next
                Call oOcc1.CreateGeometryProxy(GetProxy(oConstraint.EntityOne, oOcc1), oEntityOne)
            End If
            
            If oTestoOcc2 Is Nothing Then
                Set oEntityTwo = oConstraint.EntityTwo
            Else
                For Each oPossibleOcc In oNewlyInsertedColl
                    If oPossibleOcc.Definition Is oTestoOcc2.Definition Then
                        Set oOcc2 = oPossibleOcc
                    End If
                Next
                Call oOcc2.CreateGeometryProxy(GetProxy(oConstraint.EntityTwo, oOcc2), oEntityTwo)
            End If
        'End Grab entities
        
        
        'Check type of constraint
        Select Case oConstraint.Type
            Case 100665088 'kAngleConstraintObject
                'oParentDoc.Constraints.AddAngleConstraint(EntityOne As Object,
                '                                          EntityTwo As Object,
                '                                          Angle As Variant,
                '                                          [SolutionType] As AngleConstraintSolutionTypeEnum,
                '                                          [ReferenceVectorEntity] As Variant,
                '                                          [BiasPointOne] As Variant,
                '                                          [BiasPointTwo] As Variant )
                '                                      As AngleConstraint
                Call oParentDoc.ComponentDefinition.Constraints.AddAngleConstraint(oEntityOne, oEntityTwo, oConstraint.Angle, oConstraint.SolutionType, oConstraint.ReferenceVectorEntity)
                
            Case 100707840 'kAssemblySymmetryConstraintObject
                'oParentDoc.AddSymmetryConstraint( EntityOne As Object,
                '                                  EntityTwo As Object,
                '                                  SymmetryPlane As Object,
                '                                  [EntityOneInferredType] As InferredTypeEnum,
                '                                  [EntityTwoInferredType] As InferredTypeEnum,
                '                                  [NormalsOpposed] As Boolean )
                '                                 As AssemblySymmetryConstraint
                Call oParentDoc.ComponentDefinition.Constraints.AddSymmetryConstraint(oEntityOne, oEntityTwo, oConstraint.SymmetryPlane, oConstraint.EntityOneInferredType, oConstraint.EntityTwoInferredType, oConstraint.NormalsOpposed)
                
            Case 100666368 'kFlushConstraintObject
                'oParentDoc.AddFlushConstraint( EntityOne As Object,
                '                               EntityTwo As Object,
                '                               Offset As Variant,
                '                               [BiasPointOne] As Variant,
                '                               [BiasPointTwo] As Variant )
                '                            As FlushConstraint
                Call oParentDoc.ComponentDefinition.Constraints.AddFlushConstraint(oEntityOne, oEntityTwo, oConstraint.Offset.Expression)
                
                
            Case 100665344 'kInsertConstraintObject
                'oParentDoc.AddInsertConstraint( EntityOne As Object,
                '                                EntityTwo As Object,
                '                                AxesOpposed As Boolean,
                '                                Distance As Variant,
                '                                [BiasPointOne] As Variant,
                '                                [BiasPointTwo] As Variant )
                '                             As InsertConstraint
                Call oParentDoc.ComponentDefinition.Constraints.AddInsertConstraint(oEntityOne, oEntityTwo, oConstraint.AxesOpposed, oConstraint.Distance.Expression)
                
            Case 100665856 'kMateConstraintObject
                'oParentDoc.AddMateConstraint( EntityOne As Object,
                '                               EntityTwo As Object,
                '                               Offset As Variant,
                '                               [EntityOneInferredType] As InferredTypeEnum,
                '                               [EntityTwoInferredType] As InferredTypeEnum,
                '                               [BiasPointOne] As Variant,
                '                               [BiasPointTwo] As Variant )
                '                             As MateConstraint
                Call oParentDoc.ComponentDefinition.Constraints.AddMateConstraint(oEntityOne, oEntityTwo, oConstraint.Offset.Expression, oConstraint.EntityOneInferredType, oConstraint.EntityTwoInferredType)
                
            Case 100665600 'kTangentConstraintObject
                '.AddTangentConstraint( EntityOne As Object,
                '                       EntityTwo As Object,
                '                       InsideTangency As Boolean,
                '                       Offset As Variant,
                '                       [BiasPointOne] As Variant,
                '                       [BiasPointTwo] As Variant )
                '                     As TangentConstraint
                Call oParentDoc.ComponentDefinition.Constraints.AddTangentConstraint(oEntityOne, oEntityTwo, oConstraint.InsideTangency, oConstraint.Offset.Expression)
            
        End Select
NextConstraint:
    Next 'constraint
    
    
End Sub

Private Function GrabObjectFromColl(ByVal oColl As Collection, ByVal oObj As Object) As Object
    For Each oItem In oColl
        If oItem Is oObj Then
            Set GrabObjectFromColl = oObj
            Exit Function
        End If
    Next
    Set GrabObjectFromColl = Nothing
End Function

Private Function GetProxy(ByRef Prxy As Object, ByRef ContOcc As ComponentOccurrence) As Object
    Dim TempPrxy As Object
    Dim Occ As Object
    If Prxy.ContainingOccurrence.Type = kComponentOccurrenceObject Then
        Set Occ = ContOcc
    Else
        On Error Resume Next
            Set Occ = ContOcc.Definition.Occurrences.ItemByName(Prxy.ContainingOccurrence.Name)
            
        If Err.Number <> 0 Then
            On Error GoTo 0
            Set TempPrxy = Prxy.ContainingOccurrence
            Call ContOcc.CreateGeometryProxy(GetProxy(TempPrxy, ContOcc), Occ)
        End If
    End If
    Call Occ.CreateGeometryProxy(Prxy.NativeObject, GetProxy)
End Function

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 14 of 23

Anonymous
Not applicable

Yomacro compile fail.pngur macro does not work...

0 Likes
Message 15 of 23

skyngu
Collaborator
Collaborator

it is vba code for macro, not ilogic.

Autodesk Inventor Professional 2019
0 Likes
Message 16 of 23

Anonymous
Not applicable

Hi Michael,

 

Thanks very much for the code!  It works great!  I really appreciate it!

 

I added a small message box to the end of the code that just says, "Your components have been copied and are now placed in the assembly." - This is just so that the user knows that it worked, and they should go look for the new components.

 

Thanks again!

David Fletcher

0 Likes
Message 17 of 23

MikeKovacik4928
Advisor
Advisor

David

 

I didn't write the code. I don't know how to program.

Justin K wrote it. Thank you Justin K.

I haven't tried it yet but will do soon.

 

I am still struggling along, reconstraining items that I copy or mirror in big assemblies.

I haven't continued using imates, I found it too cumbersome to use and set up.

What I try to do now, is constrain components that I know I am going to copy and paste or mirror or pattern to each other, rather than to parts that I know are not going to be part of the copy/mirror/pattern process.

One thing that does annoy me intensely, is the fact that I have found no way to use the symmetry constraint,

in combination with the mirror command, so that when you change your base assembly, the mirrored parts move as well, not stay where they are (unless of course you reconstrain them AFTER  the mirror to some stationary planes).

However I will create a separate post for this

 

I am still wasting a lot of time, reconstraining, I think it is just the nature of beast, it has to be done.

Hopefully, as I gain experience and continue talking on the forum to others who are doing the same,

my methodology will improve.

 

Mike

0 Likes
Message 18 of 23

Anonymous
Not applicable

Hi Justin,

 

Thanks very much for the code!  It works great!  I really appreciate it!

  

Thanks again!

David Fletcher

0 Likes
Message 19 of 23

Anonymous
Not applicable

Hi Mike,

 

Sorry about the mistake; I have also thanked Justin K as well.

 

I feel your pain re: constraints with mirror, symmetry, patterns.  Inventor 2015 (what I'm currently using) is not up to the challenge, really.  Solidworks had a useful symmetric constraint command already in 2008, and it worked pretty sweet!  Inventor needs to copy better!

 

I find that in order to make things adjust correctly after an update, I have to really think ahead and create work planes that are attached to the sketch geometry, but it's only after it breaks that I realize what I could have done, and then I implement the work geometry, and then the design doesn't change much.  Inevitably.  😕

 

Thanks for your comments and discussions; they are useful and helpful!

David

 

0 Likes
Message 20 of 23

prussellZXB3F
Enthusiast
Enthusiast

I've been chipping away at an addin that gives a copy with mates like experience. I'm about to ditch  what I've got and do a from scratch rewrite but thought I'd share the early beta as can still be a useful, although buggy tool.

 

https://drive.google.com/drive/folders/1CI1ppMxqbDlYHlHe2pn8eRYhkG7AqWIK?usp=sharing

 

drop the .dll and .addin into C:\ProgramData\Autodesk\Inventor Addins

 

Regards Phil

screencast below

https://autode.sk/3ac5DGj

0 Likes