Writing a C# addin and need to get elements that are visible in the current 2d drawing model that are coming from a clipped 3d design model reference.
I know how to get to all the elements in a referenced model, trying to figure out if an element is visible in the clipped view of the reference.
Mike Robertson said:I know how to get to all the elements in a referenced model, trying to figure out if an element is visible in the clipped view of the reference
Firstly, use the MicroStation scanner. The scanner offers the opportunity to select elements spatially based on their range.
Next apply the view's range to the scanner.
ViewInformation viewInfo = viewGroup.GetViewInformation(nView); Debug.Assert(null != viewInfo); ViewGeometryInformation geometry = viewInfo.GetGeometryInformation(); DPoint3d extent = geometry.Extent; // Calculate scan range from extent
// Setup ScanCriteria criteria.SetRange(scanRange);
Regards, Jon Summers LA Solutions
Jon,
That was kind of the approach I was looking into but using the COM scanner which I couldn't get to return referenced elements. Trying Bentley.DgnPlatformNET.ScanCriteria based solution described in your article didn't return referenced elements either. Am I missing something?
Bentley.DgnPlatformNET.ScanCriteria based solution described in your article didn't return referenced elements either. Am I missing something?
I can get the elements from the reference I'm interested in. Is there a way to get their geometry in relation to the model they are referenced into?
Mike Robertson said:Is there a way to get their geometry in relation to the model they are referenced into?
I'm uncertain about your intent. Your headline is Get visible elements in clipped reference view. Either you want to get elements in a view, or you want to get elements from a clipped reference, or even a combination of both.
Whichever it is, obtain a range from a view (see previous response) or reference clip boundary (calculate from DgnAttachment.GetClipPoints() ). If you want both, you can merge ranges with methods such as Application.Range3dUnionPoint3d(). Use that range with your scan criteria ScanCriteria.SetRangeTest().
DgnAttachment.GetClipPoints()
Application.Range3dUnionPoint3d()
ScanCriteria.SetRangeTest()
Jon Summers said:I'm uncertain about your intent.
I agree, it would be nice to have an example. The "clipped reference view" can be anything from simple reference, clipped in active model, to 3D model, clipped to create a section, stored as Saved View and attached to active model.
Jon Summers said:Whichever it is, obtain a range from a view (see previous response) or reference clip boundary (calculate from DgnAttachment.GetClipPoints() ).
It's a guess only, but I am not sure whether this approach is general and can be used. When references are clipped in such way not original elements are displayed, but new are created temporarily as a representation of the clipping configuration, standard scanning probably ignores them, because they do not exists in referenced model.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Sorry Jon, got knocked out of commission for a little. Here's my situation:
I have a 3d Design Model with 3D elements that are cut into drawing models by OpenRoads Designer. The drawing model contains a cross-section and plots the section of the 3D elements from the Design Model and clips the reference view to show only a specific range of the 3D elements. I'm writing a tool to automatically label these cross sections (using itemtype information on the 3D element).
I know how to scan the elements in the reference but I need to do the following:
Is the element contained in the reference visible within the drawing model view?What are the coordinates of the cut element in drawing model coordinate so that I place the label in the correct location?
Thanks for your help.
Mike
Just a few images to help. Image 1 shows the element properties of the 3D element in the reference when checked from the drawing model (still shows the x,y of where it is located in the file it resides).
Image 2 shows it's location in relation to where it appears in the reference. I'm looking for a way to get the element location in relation to the drawing model, not the model that actually contains the element.
Mike Robertson said:I'm looking for a way to get the [referenced] element location in relation to the drawing model
There is a transform that describes the geometrical relationship of a reference model to its master model. When references are nested, there may be a chain of such transforms. I think you need to get that transform, then apply it to reference element geometry.
See DgnAttachment.GetTransformToParent().
DgnAttachment.GetTransformToParent()
Jon Summers said:I think you need to get that transform, then apply it to reference element geometry.
struct ElementGraphicsOutput{//! Visit the supplied element and send it's Draw output to the supplied processor.//! @param[in] eh The element to output the graphics of.//! @param[in] processor The object to send the Draw output to.//! @param[in] rootParent Optional parent model. If non-null attachment transform from element to parent will be pushed.//! @bsimethodDGNPLATFORM_EXPORT static void Process (ElementHandleCR eh, IElementGraphicsProcessorR processor, DgnModelRefP rootParent = NULL);
If for example, "ACTIVEMOEL" is supplied as the rootParent arg, the transform supplied to "_AnnounceTransform" will include reference to master.
It is almost always a bad idea to try to apply a reference transform to elements vs. transforming the element's geometry or just passing the geometry + transform into some api that accepts "local" coordinate geometry + localToWorld transform.
With elements you have to consider things like 2d attachments to 3d not being able to apply a 3d transform, or the element's handler not supporting some transforms, ex. the handler for an ibeam application element might disallow scale, etc. Basically calling "ApplyTransform" on an element can fail so don't do it.
HTH
-B
Thanks Jon, using the DgnAttachment.GetTransformToParent() method got me the correct information for where reference elements are located within the active model.
Hello John,
I cannot find attachement.getClipPoints() function in VBA for Microstation Connect R12
Do you have any solution to get reference clip Points in VBA ? (i.e.wrapping an mdl function)
Many thanks
Rémy
Hi Rémy,
Rémy Weill said:I cannot find attachement.getClipPoints() function in VBA for Microstation Connect R12
please respect the best practices and do not steal the discussion by posting new topic.
This discussion is about using C# in Update 14. If you want to discuss VBA in Update 12, please post the new question.
With regards,