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?
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?
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