[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

Parents
  • 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

Reply
  • 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

Children
No Data