Hi!
I want to clip a DgnAttachment by an shape element.
The shape element is in the DgnAttachment itself.
I have tried the DgnAttachment::SetClipElementId(),and find out it can only pass elid which is in the master model.
Can anyone help me?
Hi,
as usually, please follow the forum best practices! Do you think when discussion API, conditions and context is the same for current CE Update 14 API and original CE version, released nearly 5 years ago?
wanglin said:I have tried the DgnAttachment::SetClipElementId(),and find out it can only pass elid which is in the master model.
Yes, it's mentioned in the method description: ERROR if an element with the specified element ID is not found with the DgnAttachment's DgnModel.
wanglin said:Can anyone help me?
I think you have to find the element in the attachment, extract its vertices and to use e.g. SetClipPoints() or SetClipBoundFromViewPoints().
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
OK! thanks for mention me about the new rule.
SetClipPoints() maybe ok. But i also want the clip range can associate with the shape element when user modify the shape element.
wanglin said: i also want the clip range can associate with the shape element when user modify the shape element.
That's hard: it's probably why Bentley don't let you cite a referenced element in SetClipElementId().
SetClipElementId()
The approach I recommend is to look at the Dependency Manager function family. That lets you nominate a DGN element to be a dependent of something, and to fire a notification when that something changes. A dependency can specify an element in an attachment
However, there's a logical problem. When a user changes the shape that defines your clip boundary, she is editing that model directly — it's the active model, no longer a reference. The dependency change won't be received by your code because that's linked to the object in a file that is no longer open. When you return to that file, the reference has been closed for editing, so there's nothing to raise a dependency event.
That's plenty to think about!
Regards, Jon Summers LA Solutions
wanglin said:But i also want the clip range can associate with the shape element when user modify the shape element.
I think even MicroStation does not work this way and does not allow to create dependency from reference back to parent model. Or do you have some example, that can be done using standard MicroStation tools?
I agree with Jon it cannot be solved simply and even when Dependency Manager seems to be the way to go, I expect blockers exist to establish notification from reference (which is read-only by default) back to active model.
Hi wanglin,
I agree with Jan and if you need to define your own local coordinate system point array, populate that array from an input element (verticies or range), fence, or view points and call SetClipBoundFromViewPoints(), like this example code snip using active fence points as input:
StatusInt status = refP->SetClipBoundFromViewPoints (tcb->fenpts, tcb->fence, viewMatrix, viewOrigin, viewActiveZ, discardClipMasks);
HTH,Bob
Thank you,i will try the Dependency and to see if it can do what i want.
Hi, Jan.
Infact Microstation does have the tool for user to do what i want.
Thanks, but i just don't want that effect.
As i mentioned in the reply to Jan's answer. The Microstation have the tool for user to implement what i want.
And i just want to implement that with code in my program.
I have confirmed the public method SetClipElementId (as documented) only permits near element ids, where the Attachment internal method is permitted to provide far (non-active model) element ids.
The current, best and only work-around (today) would be to: perform a (post) locate, use the hit path of the selected element, then extract its boundary shape point array passing to SetClipBoundFromViewPoints. I don't see any other practical way to achieve this.
I will check to see if an enhancement is appropriate and if so, update this thread with the number once approved.
wanglin said:Infact Microstation does have the tool for user to do what i want.
thanks a lot for the explanation. I was not aware of it's possible to use far (from reference) element. Learned something new :-)
wanglin said:The "Clip Reference" tool can select a shape in the DgnAttachment itself.
I quickly (limited time available) checked what happens with the attachment and clip element, when the clip is defined. It seems, that:
It confirms Jon's idea about Dependency Manager.
I guess when MicroStation does it, you should be able to do it also. But I have very limited experience using Dependency Manager directly (as discussed in the past, it's very low level technology, that is behind a lot of functionality, but rarely used directly).
With regards,