Insert block at Centroid of Region

Discussion in 'AutoCAD' started by DaleB, Jul 20, 2004.

  1. DaleB

    DaleB Guest

    I am trying to get a block inserted at the centroid of a region I have
    created but can't seem to get it to work.

    What I have is:

    Set Bucket(0) = ent.Copy
    Set entR = ThisDrawing.ModelSpace.AddRegion(Bucket)
    cent = entR.Centroid
    Set blockRef = ThisDrawing.ModelSpace.InsertBlock(cent, "PID1", 1,
    1, 1, 0)

    but cent keeps coming up empty, how do I get the centroid for entR into the
    insertion point slot? The region gets created in the drawing okay but
    nothing seems to be getting returned to entR, I can't use this variable to
    do anything with the region after it is created.
     
    DaleB, Jul 20, 2004
    #1
  2. DaleB

    MP Guest

    hint
    per help on addregion:
    RetVal
    Variant
    This method outputs an array of the newly created Region objects

    an array won't have a centroid
    :)

    you must have had an 'on error resume next' in there somewhere or you'd have
    seen where your error was occuring


    what would
    cent = entR(0).Centroid do?
    and of course drop the Set from
    hth
    Mark
     
    MP, Jul 21, 2004
    #2
  3. DaleB

    DaleB Guest

    Thanks for your help Mark, I've got it now.

    Dale
     
    DaleB, Jul 21, 2004
    #3
  4. DaleB

    MP Guest

    cool!
    You're welcome.
    :)
     
    MP, Jul 21, 2004
    #4
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.