Positioning MDT-assembly

Discussion in 'AutoCAD' started by simu, Aug 22, 2003.

  1. simu

    simu Guest

    I'm using the "AddComponent" method to add an assembly in my MDT-drawing. Can someone explain how to use the matrix-property ? I want the user to select the position on the screen to place the definition ?

    Thanks,
    Ivo
     
    simu, Aug 22, 2003
    #1
  2. simu

    Kevin Terry Guest

    Hi, this is directly cut from an application I developed to do this task, let me know if you have any questions:



     



    Private Sub cmdAttach_Click()
       
        Dim mcApp As McadApplication
        Dim geApp As GeApplication
        Dim mcAssyMgr As McadAssemblyMgr
        Dim mcDef As McadComponentDefinition
        Dim mcComp As McadComponent
        Dim geMat As GeMatrix
        Dim gePt As GePoint
        Dim geVec1 As GeVector
        Dim sShopPath As String
        Dim vPoint As Variant
        Dim sSelect As String
        



        'make references
        Set mcApp = ThisDrawing.Application.GetInterfaceObject("Mcad.Application")
        Set mcAssyMgr = mcApp.ActiveDocument.AssemblyMgr
        Set mcDef = mcAssyMgr.RootDefinition
        Set geApp = ThisDrawing.Application.GetInterfaceObject("Ge.Application")
        Set geMat = geApp.Matrix



        
        'this control houses the full path of item selected
        sSelect = txtComp.ControlTipText
        
        'attach selected item
        On Error GoTo Err_Attach
        Set mcDef = mcAssyMgr.AddCompDefFromFile(sSelect)
        
        'get insertion point from user
        Me.Hide
        vPoint = ThisDrawing.Utility.GetPoint(, "Select insertion point")
        Set gePt = geApp.Point(vPoint(0), vPoint(1), vPoint(2))
        Set geVec1 = gePt.AsVector
        geMat.Translation = geVec1
       
        'make attachment
        Set mcComp = mcAssyMgr.ActiveDefinition.AddComponent(mcDef, geMat)
        
        If Err.Number = 0 Then GoTo Exit_App
       
    Err_Attach:
       
        MsgBox "Error on attaching subassembly: " & Err.Description, vbExclamation + vbOKOnly
       
    Exit_App:
        
        Set mcApp = Nothing
        Set geApp = Nothing
        Set mcAssyMgr = Nothing
        Set mcDef = Nothing
        Set mcComp = Nothing
        Set geMat = Nothing
       
    End Sub




    Note that due to an omission in Autodesk's object model, there is no way to show the 'ghost' outline of the part coming in for attachment. So the user will not see what it is they are attaching, but will be able to pick the point. Also note this is all relative to WCS.



     



    Kevin



    "simu" <> wrote in message news:...

    I'm using the "AddComponent" method to add an assembly in my MDT-drawing. Can someone explain how to use the matrix-property ? I want the user to select the position on the screen to place the definition ?

    Thanks,
    Ivo
     
    Kevin Terry, Aug 22, 2003
    #2
  3. simu

    simu Guest

    Thanks Kevin,

    This works OK.
    Still a question; It inserts the assembly by its absolute insert point. How can I use the Center of Geometry.
    Like the option in Assist_MechanicalOptions_Assembly.

    Ivo
     
    simu, Aug 25, 2003
    #3
  4. simu

    Kevin Terry Guest

    I'm not sure if this is an option through the code itself - have you verified your setting under options is set to the COG instead?




    Kevin



    "simu" <> wrote in message news:...

    Thanks Kevin,

    This works OK.
    Still a question; It inserts the assembly by its absolute insert point. How can I use the Center of Geometry.
    Like the option in Assist_MechanicalOptions_Assembly.

    Ivo
     
    Kevin Terry, Aug 25, 2003
    #4
  5. simu

    simu Guest

    Hi Kevin,
    Yes, although the options is COG, its uses the absolute insert point.
    The method described I think uses the Autocad-way of picking a point. If you look at the pick-method in the MDT-methods (in the help) it looks like it can use the ghost etc.
    But this describes the selection of an object not of a point. This all stuff is still a little too complicated for me, but maybe this will give a hint.
    If you find something, please let me know,
    Thanks,
    Ivo
     
    simu, Aug 25, 2003
    #5
  6. simu

    Kevin Terry Guest

    Well, I was going to suggest you could use the center of gravity of the part to move it relative to the picked point, but according to the help file:



    (search for center of gravity)



    Note: Currently, this method is not implemented.



     



    Syntax



     



    RetVal = object.GetMassProperties(Volume, CenterOfGravity, Moments, Products, RadiiOfGyration, PrincipalAxes, PrincipalMoments [, Tolerance])




    Sorry I couldn't be more help...
    Kevin



    "simu" <> wrote in message news:...

    Hi Kevin,
    Yes, although the options is COG, its uses the absolute insert point.
    The method described I think uses the Autocad-way of picking a point. If you look at the pick-method in the MDT-methods (in the help) it looks like it can use the ghost etc.
    But this describes the selection of an object not of a point. This all stuff is still a little too complicated for me, but maybe this will give a hint.
    If you find something, please let me know,
    Thanks,
    Ivo
     
    Kevin Terry, Aug 25, 2003
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.