I'm writing an application where 3D cones are placed in a 3D model (my cones have the same radius on top an bottom so they look like cylinders). Named boundaries are created at each of the cones, and a Drawing model is created from the named boundary. I then need to find the center of the referenced cone in the drawing model to place some annotation.
I am able to retrieve the cone element in the drawing model, but when I get the range of the element it is all ways too wide. The top and bottom of the range are correct, but the low.x & high.x are not correct, the cone is located within the low & high X value. See image below. It's strange because the width from cone to cone varies even though all the cones are the same width. Examples below.
.
Looking at a few other range posts, it appears this may happen on very small elements. These cones are 2.5' x 10' (for us that is 762,000 x 3,048,000 units), so I wouldn't think that is the problem.
I've tried three different methods and get the same result.
1) Using COM, I fit and fence the view, as below code
BMI.Utilities.ComApp.CadInputQueue.SendCommand("fit view extended 1"); BMI.Utilities.ComApp.CadInputQueue.SendCommand("place fence view 1"); BIM.Fence fence = BMI.Utilities.ComApp.ActiveDesignFile.Fence; //other code here that gets the element I'm looking for using itemtype properties BIM.Range3d range3d = element.Range
2) Using .NET code I'm able to retrieve the element by using the above method to get the element ID I'm looking for, then parsing a list of DgnECInstances and finding the correct element in the reference. Then I transform that referenced element to the current model. And get the range.
DgnModelRef dgnModelRef = dgnECInstance.Element.DgnModelRef; DgnAttachment dgnAttachment = dgnModelRef.AsDgnAttachment(); DTransform3d dTransform3D = new DTransform3d(); dgnAttachment.GetTransformToParent(out dTransform3D, true); TransformInfo transformInfo = new TransformInfo(dTransform3D); ConeElement coneElement = (ConeElement)dgnECInstance.Element; coneElement.ApplyTransform(transformInfo); DRange3d coneRange; coneElement.CalcElementRange(out coneRange);
3) Using the same element above to find the cone element, looking at it's ECProperty values I can retrieve the element range.
All 3 methods produce the exact same range results.
It's an axis aligned range box, unless you happen to be viewing the cylinder from a front/back/left/right view and it's a coincident attachment (because you are apply the attachment transform to the element) the range box can be wider than the cylinder...
The "set range" key-in (result shown above) may help you understand better. It's a toggle, update the view after to show/clear the range box display...
HTH
-B
Thanks Brian, I figured it must be something like that. I was trying to use the Cone center & radius properties instead of rang,e but the values I was getting were very small and appeared to not be located in the correct location. I also tried to use a property handler to retrieve what is shown in the properties dialog when I select the cone (it shows the correct range) but trying to use a property handler on an element in a reference seems to throw and exception. I'll look more into the center/radius & properties handler options some more.