Great problem whit centroid

Discussion in 'AutoCAD' started by fazzini, Apr 1, 2004.

  1. fazzini

    fazzini Guest

    I have get a function in this forum for get the centroid to single object:

    Public Function EntityCentroid(Entity As AcadEntity) As Double()
    Dim EntityArray(0) As AcadEntity
    Dim RegionList As Variant

    MakeUCS

    Set EntityArray(0) = Entity
    RegionList = ThisDrawing.ModelSpace.AddRegion(EntityArray)
    EntityCentroid = RegionList(0).Centroid
    RegionList(0).Delete
    End Function

    After i add the MakeUCS which make and active a UCS for draw correctly the region.
    The region are drawing but when i call the regionlist(0).Centroid VBA show me this error:
    "Region is not in the current UCS plane." error -2145320934 (8021001a)


    This is my MakeUCS function:

    Public Sub MakeUCS()
    Dim UCSObj As AcadUCS
    Dim Origin(0 To 2) As Double

    Origin(0) = 0
    Origin(1) = 0
    Origin(2) = 0

    Set UCSObj = ThisDrawing.UserCoordinateSystems.Add(Origin, ThisDrawing.Utility.TranslateCoordinates(ThisDrawing.GetVariable("UCSXDIR"), acUCS, acWorld, 0), ThisDrawing.Utility.TranslateCoordinates(ThisDrawing.GetVariable("UCSYDIR"), acUCS, acWorld, 0), "UCSFazzini")
    ThisDrawing.ActiveUCS = UCSObj
    ThisDrawing.Application.Update
    End Sub


    Please help and sorry for my english.
     
    fazzini, Apr 1, 2004
    #1
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.