- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Greetings,
I've been making a add-in for Robot to move a selected structure based on a origin referential frame and a destination referential frame (allowing to translate+rotate+scale in a single instruction). I got this part working, but now I want to add a option to copy instead of moving.
I can create new bars with Bars.Create but then I have to set all properties equal to the original bars, and also I have to Get the new bar from model after creating it. Copying a bar seems to be a simple task, but can't find examples of doing this directly. Any ideas to accomplish this in any simple way?
Here's my code (C#) at the moment, where "Transform()" gives the new coordinates, and "newfrom" keeps track of the old and new points, "Rnodes" and "Rbars" are RobotNodeCollection and RobotBarCollection respectively.
//list of original and translated points
Dictionary<int, int> newfrom = new Dictionary<int, int>();
// node creation
for (int i = 1; i <= Rnodes.Count; i++)
{
RobotNode no = Rnodes.Get(i);
Vector3 result = Transform(new Vector3((float)no.X, (float)no.Y, (float)no.Z));
int id = robapp.Project.Structure.Nodes.FreeNumber;
robapp.Project.Structure.Nodes.Create(id, result.X, result.Y, result.Z);
newfrom.Add(no.Number, id);
}
// bar creation
for (int i = 1; i <= Rbars.Count; i++)
{
RobotBar bar = Rbars.Get(i);
int id = robapp.Project.Structure.Bars.FreeNumber;
int node1 = newfrom[bar.StartNode];
int node2 = newfrom[bar.EndNode];
robapp.Project.Structure.Bars.Create(id, node1, node2);
RobotBar newbar = (RobotBar)robapp.Project.Structure.Bars.Get(id);
}
Solved! Go to Solution.