i'm trying to make Instance of Selected object entered by the user in Revit Api 2012 c#,I discovered that the third input to ElementTransformUtils.CopyElement is the translation vector not the new place so i'm trying to pick fixed point from the element selected then substract the new place location from it and put the result as translation vector. the problem is : i use pickobject.globalPoint to obtain point from the selected object which changes every time i ran the code so the Question : how to obtain the same point every time i select the Element Entered by the user? Thanks In Advance
Asked
Active
Viewed 1,375 times
1 Answers
0
Select the original element as explained here: create Instances of Selected object Revit Api
Retrieve the element's location as follows:
Location location = originalElement.Location;
LocationPoint locationPoint = location as LocationPoint;
if (locationPoint != null)
{
XYZ originalPoint = location.Point;
}
Select a location for the new element as follows:
UIDocument uidoc = this.ActiveUIDocument;
XYZ newPoint = uidoc.Selection.PickPoint("Select a location for the element");
Create the translation vector:
XYZ translationVector = newPoint - originalPoint;
Copy the element:
Document doc = uidoc.Document;
ICollection<ElementId> copiedElementIds = ElementTransformUtils.CopyElement(doc, originalElement.Id, translationVector);
According to the API docs, the reason an ICollection is returned as opposed to a single ElementId is: "More than one element may be created due to dependencies."

Community
- 1
- 1

Colin Stark
- 591
- 3
- 15
-
ok,thank you..but can i ask you if the Element is detail line and i want to make copies from it and the problem is the location is null..How to solve this pb?Thanks In Advance :) – user2177723 Sep 13 '13 at 01:49