Setting the position of components in a flexible subassembly

Setting the position of components in a flexible subassembly

maarten_joosten
Explorer Explorer
340 Views
3 Replies
Message 1 of 4

Setting the position of components in a flexible subassembly

maarten_joosten
Explorer
Explorer

Hello,

 

I am placing multiple components using a C# addin, but one of them is flexible and not of the correct length, see below. How can I set the flexible component to the position I want?

FlexibleSubAssembly.png

 

I've tried moving the component directly, but this does not change the position, see example below. I've also tried modifying the model parameter of the MateConstraint, but that throw an exception with E_FAIL.

 

 

 

Beam beam = Selected.Beams.First();
ComponentOccurrence component = Components.Get(beam);

component.Flexible = true;

ComponentOccurrence[] clamps = component.SubOccurrences.Cast<ComponentOccurrence>().Where(c => c.Name.StartsWith("02-008")).ToArray();

Vector translation = Context.Application.TransientGeometry.CreateVector(946.2437, 0, 8.12);

clamps[1].Transformation.SetTranslation(translation);

 

 

 

 

Beam beam = Selected.Beams.First();
ComponentOccurrence component = Components.Get(beam);

double length = beam.Length * 100;

component.Flexible = true;

ComponentOccurrence[] clamps = component.SubOccurrences.Cast<ComponentOccurrence>().Where(c => c.Name.StartsWith("02-008")).ToArray();
MateConstraint[] mates = clamps.SelectMany(c => c.Constraints.OfType<MateConstraint>().Where(mate => mate.ConstraintLimits.MinimumEnabled && mate.ConstraintLimits.MaximumEnabled)).ToArray();

foreach (MateConstraint mate in mates) {
	mate.Offset.Value = length;
}

 

 

 

Thanks in advance

0 Likes
Accepted solutions (1)
341 Views
3 Replies
Replies (3)
Message 2 of 4

Frederick_Law
Mentor
Mentor

You need to set the subassembly as Flexible in the assembly.

0 Likes
Message 3 of 4

maarten_joosten
Explorer
Explorer
clamps[1].Flexible = true;

Setting either the clamps or the middle part as flexible throw with E_FAIL. On top of that, moving the component manually doesn't need setting the subassemblies to flexible, only the main one.

0 Likes
Message 4 of 4

maarten_joosten
Explorer
Explorer
Accepted solution

Update: a colleague of mine suggested adding an constraint on the clamp, which works.

0 Likes