[CE U13 VBA] Get Origem point of selected group

Hi,

I'm using the commands "POWERSELECTOR ALL " and  "GROUP SELECTION " To select all elements and group to move all together. But I need get (X,Y) point of start point. I'm having difficult to get it. 

Can you help me how I get this information?

Thank you

  • Hi Naime,

    again ... even when it's better than previous post, I still have to ask to follow best practices better. Version is still missing. There have been 15 versions of MicroStation CONNECT Edition released so far and the situation can be different when discussed for e.g. Update 1 or current Update 13.1. So is it [CE U13 VBA] (or even better [MStn CE U13 VBA] because not only MicroStation issues are discussed in this forum)?

    But I need get (X,Y) point of start point.

    It's not "start point" (as used in text) and also not "origin point" (as written in the subject).

    I assume you are aware that when elements are grouped, unnamed cell is created. In this context, "start point" term is not defined and based on quick test it seems that an origin of the created cell is in a center of the cell, so it's defined, but it's somewhere else than what you need ;-)

    Can you help me how I get this information?

    What is "start point" for you?

    If it's the position of lower left cell handle, I assume it's equal to the cell range block. In such case just get range.low coordinates of the cell.

    You should be aware that the range block is not "minimum / maximum coordinates of the cell content", but it's a minimal block around an element(s), expressed in integer coordinates. It means it's slightly smaller or bigger (depending whether it's about high or low range) than is element(s) size.

    With regards,

      Jan

  • I'm using the commands "POWERSELECTOR ALL " and  "GROUP SELECTION " To select all elements and group to move all together. But I need get (X,Y) point of start point

    It looks like you intend to queue MicroStation commands (show us your code).  Have you recorded a VBA macro?

    MicroStation doesn't care about the absolute coordinates: it wants a start and end point to determine the move vector.  Your intentions will become clearer to us when you post your VBA code.

     
    Regards, Jon Summers
    LA Solutions

  • Hi, 

    Jan, Jon, thank you for your comments.

    Adding more information about that I need to be more clear. 

    I'm Creating a new .dgn using FF=<File Location>. That is working good. However in the new .dgn create, my sheet does not start on (0,0) point (they use the position of source sheet, and that is OK).

    Why I need this new .dgn on 0,0?  We have a other macro to generate export as .eps, .png and .cgm. We work to export in mass (all .dgn in the same folder) and for works, we use fence start point as 0,0 and end point as Sheet Size choose by user. 

    I'm trying the position to (0,0) to export macro works, this will run before Export Macro. 

    So is it [CE U13 VBA]

    Updated Title.

    What is "start point" for you?

    If it's the position of lower left cell handle

    Exactly, position of lower left is my "start point"  but I don't know how get this values.

    Have you recorded a VBA macro?

    Yes, I have here. 

    Function MoveToAbsolutePoint()
    
        CadInputQueue.SendCommand "POWERSELECTOR ALL "
        CadInputQueue.SendCommand "GROUP SELECTION "
        CadInputQueue.SendCommand "MOVE ICON"
        
        'I NEED DEFFINE X and Y OF GROUP HERE 
        
        '   Coordinates are in master units
        startPoint.X = XGroup
        startPoint.Y = YGroup
        startPoint.Z = 0#
    
    '   Send a data point to the current command
        point.X = startPoint.X
        point.Y = startPoint.Y
        point.Z = startPoint.Z
        CadInputQueue.SendDataPoint point, 1
    
        point.X = 0
        point.Y = 0
        point.Z = 0
        CadInputQueue.SendDataPoint point, 1
    End Function

  • I'm using the commands "POWERSELECTOR ALL " to select all elements. Position of lower left is my "start point"

    Use ActiveModelReference.Range to get the range box around all elements in the active model. Then use Range.Low in your code. You don't need to group those elements unless you need an anonymous cell for other purposes.

     
    Regards, Jon Summers
    LA Solutions

    Answer Verified By: Naime Andere 

  • Use ActiveModelReference.Range
    Then use Range.Low

    Perfect.. I used it, and got more information into your site and adapted that I Need. 
    Works perfectly. 

    Function MoveToAbsolutePoint()
    
        Dim point As Point3d
        Dim startPoint As Point3d
        Dim range As Range3d
        Dim oModel As ModelReference
        Const IncludeAttachments As Boolean = False
    
        CadInputQueue.SendCommand "POWERSELECTOR ALL "
        CadInputQueue.SendCommand "GROUP SELECTION "
        CadInputQueue.SendCommand "MOVE ICON"
        
        'Get Group position
        Set oModel = ActiveModelReference
        range = oModel.range(IncludeAttachments)
    
    '   Coordinates are in master units
        startPoint.X = range.Low.X
        startPoint.Y = range.Low.Y
        startPoint.Z = 0#
    
    '   Send a data point to the current command
        point.X = startPoint.X
        point.Y = startPoint.Y
        point.Z = startPoint.Z
        CadInputQueue.SendDataPoint point, 1
    
        point.X = 0
        point.Y = 0
        point.Z = 0
        CadInputQueue.SendDataPoint point, 1
        
    End Function