I have ConeElements in a reference model that I'm trying to use the ConeElements center location and radius after being transformed to the referencing model. Once the transform is complete the range of the element is correct but the center point and radius are incorrect, very small.
Here is the code:
//element retrieved from a list of DgnECInstances DgnModelRef dgnModelRef = element.DgnModelRef; DgnAttachment dgnAttachment = dgnModelRef.AsDgnAttachment(); DTransform3d dTransform3D = new DTransform3d(); //pre transform ConeElement coneElement = (ConeElement)element; DRange3d coneRange; coneElement.CalcElementRange(out coneRange); //transform dgnAttachment.GetTransformToParent(out dTransform3D, true); TransformInfo transformInfo = new TransformInfo(dTransform3D); coneElement.ApplyTransform(transformInfo); coneElement.CalcElementRange(out coneRange);
Here is the results:
The range transforms correctly, but notice the values for center point, the X value should fall between the range high & low X values (unless I'm missing something.)
Looks like garbage values...
Are you sure coneElement is still a valid CONE_ELM post transform? For example, applying a non-uniform scale to a CONE_ELM can result in a BSPLINE_SURFACE_ELM since the CONE_ELM structure can't represent some results.
I almost never transform elements and instead transform the extracted data, it's a lot more robust and efficient this way. There are a number of reasons trying to apply a transform to an element might fail, 2d attached to 3d, element's handler doesn't support the transform (ex. can't scale ABD forms), etc.
HTH
-B
I'm not a super transform person, what I wanted to do originally was get the center of the coneelement and transform the center top and bottom points to the master model system but I'm really struggling with that transformation.
I wrote a test code snippet as below:
private static void TransformConeElemInRef() { DgnModel activeModel = Session.Instance.GetActiveDgnModel(); foreach (DgnAttachment dgnAttach in activeModel.GetDgnAttachments()) { ConeElement coneElem = dgnAttach.GetDgnModel().FindElementById((ElementId)1941L) as ConeElement; if (!coneElem.IsValid) continue; MessageCenter.Instance.ShowInfoMessage(coneElem.BottomCenter.ToString() + ", " + coneElem.BottomRadius.ToString(), null, false); DTransform3d trans = new DTransform3d(); dgnAttach.GetTransformToParent(out trans, true); TransformInfo transInfo = new TransformInfo(trans); coneElem.ApplyTransform(transInfo); MessageCenter.Instance.ShowInfoMessage(coneElem.BottomCenter.ToString() + ", " + coneElem.BottomRadius.ToString(), null, false); } }
And got following two lines(in my red frame) output in message center. It matchs what I observed.
My tested 2 dgn files attached as well.
Reference.7z
Why would the radius change (unless you scaled the reference)?
I ran your files and code (changed the reference scaling to 1) and the radius remains constant. Testing now on my files, the only different is my cone is in a 3D model that is referenced into a Drawing model contained in the same file.
Yongan,
Doing some more investigation. If I manually create a drawing model and reference in my cone the center point & radius is correct in code. BUT if the drawing model is created from a named boundary and the same cone is referenced in as part of the process the cone properties are not correct. See image below.
Drawing Model can only be a 2D model. Are you sure you want reference a 3D design model directly to a 2D drawing model? Normally we should create a saved view by using one of Detailing tool and then reference this saved view into drawing model.
Not sure if ustn & ORD work differently but the drawing model I'm trying to process is one created by the ORD automated creation tools. If I create that model and reference by hand my code works correctly, the drawing model created by the automated tool is causing the issue.