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
Hi Mike,
in C++ I would probably start with IElementGraphicsProcessor with ViewContext set to the clipped view. But it's just an idea, I have not tested it, so I am not sure whether it works this way.
Unfortunately, I think this functionality of IElementGraphicsProcessor is not available in NET API.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
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?
Mike Robertson said:Am I missing something?
The scanner works with a DGN model. If you're working with a referenced model, then call that model's Scan() method.
There's no API that gets all elements from the active model and its references. Programmatically, you must enumerate all models (references) and get their elements...
VBA ModelReference.Scan()
ModelReference.Scan()
.NET
// Get elements of active model DgnModelP model = ISessionMgr::GetActiveDgnModelP (); if (nullptr != model->GetGraphicElementsP ()) { // Do something with active elements }
// Get elements of referenced models DgnAttachmentCollection attachments = model.GetDgnAttachments (); foreach (DgnAttachment attachment in attachments) { // Do something with referenced elements }
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?
Jan,
There is a Bentley.DgnPlatformNET.ElementGraphicsProcessor object, I'll see if I can find any information related that might help me out.
Thank you.
Mike Robertson said:There is a Bentley.DgnPlatformNET.ElementGraphicsProcessor object,
Yes, for sure this class exists. My experience is that it's, after tool-related classes, on from the most important class in MicroStation API. The problem is that the implementation is not equal to IElementGraphicsProcessor in C++ and some methods (functionality) are not available e.g. AnnounceContext.
But I have no experience with using the processor with clipped content, so I am not sure whether the missing functionality is (not) required.
With regards,
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.
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