acadPoint.cordinates

Discussion in 'AutoCAD' started by irfan, Dec 13, 2004.

  1. irfan

    irfan Guest

    hi,

    I am declaring an acadPoint and trying to populate its x,y &z cordinates using its cordinates property ,but it gives an error
    "Object reference not set". Here is the code

    dim acadPt as acadPoint

    acadPt.coordinates(0) = 0
    acadPt.coordinates(1) =1
    acadPt.coordinates(2) =2

    I understand that i have not instantiated acadPt but when i use 'new' it says 'new' is a private property, so cant do that.
    Can someone please guide as to how to populate an instanace of acadPoint.

    regards,
    irfan
     
    irfan, Dec 13, 2004
    #1
  2. irfan

    DRW1975 Guest

    I don't think you're allowed to define the coordinates in that way. if you wanted to do it you need to do this:

    Dim acadPT As AcadPoint
    Dim NewPoint(2) As Double
    NewPoint(0) = 0: NewPoint(1) = 1: NewPoint(2) = 2
    Set acadPT = ThisDrawing.ModelSpace.AddPoint(NewPoint)

    assuming you wanted to put it in model space of course

    I think the .coordinates code is only for extracting information, not for input. Meaning :

    a = acadPT.coordinates(2)
    ' a would be equal to the value 2

    I don't know what the proper programming term would be for this kind of an argument, as i am not a programmer.

    DRW
     
    DRW1975, Dec 13, 2004
    #2
  3. Irfan, Give this a shot... one way to do it..
    gl, Paul

    '****Start
    Dim objPoint As AcadPoint
    Dim dPTS(2) As Double
    Dim vPTS As Variant
    'Set your Points...
    dPTS(0) = 10
    dPTS(1) = 10
    dPTS(2) = 0

    Set objPoint = ThisDrawing.ModelSpace.AddPoint(dPTS)
    'Dump dPTS into a variant variable, Then you only need
    'to redefine the values to Change...
    vPTS = dPTS
    'Change necessary values, I only Change X here.
    'Change all if you want...vPTS(1), vPTS(2)
    vPTS(0) = 25
    'Move your object
    objPoint.Move dPTS, vPTS
    '***End
     
    Paul Richardson, Dec 13, 2004
    #3
  4. irfan

    DRW1975 Guest

    Sorry,
    i misread the question, I agree with Paul, you will have to move your point.

    DRW
     
    DRW1975, Dec 13, 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.
Similar Threads
Loading...