[CONNECT NET] How to transform or move TextElement

Hi,

I use following code to move elements, but it doesn't work for text elements, microstation connect crashes when replace element. What is wrong?

Dim oTransform2 As DTransform3d = DTransform3d.FromTranslation(oPMove.X, oPMove.Y, oPMove.Z)
Dim oTInfo2 As BDPN.TransformInfo = New BDPN.TransformInfo(oTransform2)

oElement.ApplyTransform(oTInfo2)

oElement.ReplaceInModel(oElement)


many thanks

Parents
  • How do you declare oElement?  Is that a TextElement?

    Where does oElement come from: do you read it from a DGN model or is it a new TextElement?

     
    Regards, Jon Summers
    LA Solutions

  • Hi Jon, I create a command class with DgnElementSetTool and I take oElement from OnDataButton overrides function:

    Dim oHitPath As Bentley.DgnPlatformNET.HitPath = DoLocate(ev, True, 1)
    Dim oElement As Bentley.DgnPlatformNET.Elements.Element

    If oHitPath IsNot Nothing Then

    oElement = oHitPath.GetHeadElement()

    Dim oTransform2 As DTransform3d = DTransform3d.FromTranslation(oPMove.X, oPMove.Y, oPMove.Z)
    Dim oTInfo2 As BDPN.TransformInfo = New BDPN.TransformInfo(oTransform2)

    oElement.ApplyTransform(oTInfo2)

    oElement.ReplaceInModel(oElement)


    End If


    Code works fine with other elements types like LineStrings, Shapes, Solids, ComplexString, Cells, ... but not in text elements. Really I don't understand.
  • Unknown said:
    I create a command class with DgnElementSetTool

    Where did you find DgnElementSetTool?  I don't see it in the DgnPlatformNet documentation.

     
    Regards, Jon Summers
    LA Solutions

  • Hi Jon,

    I've found DgnElementSetTool on C# CONNECT SDK examples (p.e. ManagedToolsExample). I want to create a tool to select a single element (any type) and move it:

    Public Class CommandExample

    Inherits Bentley.DgnPlatformNET.DgnElementSetTool

    ...

     

    Is there any other way to do it? Do you think DgnElementSetTool is the problem?

    many thanks,

  • Unknown said:
    Is there any other way to do it? Do you think DgnElementSetTool is the problem?

    The problem with DgnElementSetTool, and one or two others that appear in the SDK examples, is that they don't appear in the documentation.  Consequently, we don't know if they are formally supported, introduced illegally into the SDK examples, or perhaps they exist only in some pre-release build of MicroStation CONNECT available  to Bentley Systems internal developers but never published.

     
    Regards, Jon Summers
    LA Solutions

  • The problem is not with DgnElementSetTool, as I am able to reproduce it by grabbing the selected elements with the SelectionSetManager...  

    However, going back to my suggestion seems to take care of the problem.

                foreach (Element selectedElement in selectedElements)
                {
                    IntPtr elementRef = selectedElement.GetNativeElementRef();
                    
    
                    TransformInfo tinfo = new TransformInfo(DTransform3d.FromTranslation(1000,1000,1000));
                    selectedElement.ApplyTransform(tinfo);
                    
                    Element originalElement = Element.GetFromElementRef(elementRef);
                    selectedElement.ReplaceInModel(originalElement);
    
                }

    Answer Verified By: Francesc Calaf 

Reply
  • The problem is not with DgnElementSetTool, as I am able to reproduce it by grabbing the selected elements with the SelectionSetManager...  

    However, going back to my suggestion seems to take care of the problem.

                foreach (Element selectedElement in selectedElements)
                {
                    IntPtr elementRef = selectedElement.GetNativeElementRef();
                    
    
                    TransformInfo tinfo = new TransformInfo(DTransform3d.FromTranslation(1000,1000,1000));
                    selectedElement.ApplyTransform(tinfo);
                    
                    Element originalElement = Element.GetFromElementRef(elementRef);
                    selectedElement.ReplaceInModel(originalElement);
    
                }

    Answer Verified By: Francesc Calaf 

Children