Results 1 to 8 of 8

Thread: acadPoint.cordinates

  1. #1
    irfan Guest

    acadPoint.cordinates

    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

  2. #2
    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

  3. #3
    DRW1975 Guest
    Just looking up the acadpoint object in my reference book (AutoCAD 2000 VBA - Sutphin).

    It states that(paraphrasing) .coordinates gets or sets a three-element array of doubles containing 3d coordinates in WCS.

    so it wants to look for an array.
    oddly enough, from my previous message, a=acadPT.coordinates(2) actually works though...

    DRW

  4. #4
    Paul Richardson Guest
    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

    "irfan" <nospam@address.withheld> wrote in message
    news:13626397.1102937893093.JavaMail.jive@jiveforu m1.autodesk.com...
    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

  5. #5
    irfan Guest
    thanks paul and DRW for ur suggestions
    Cant use Variant, as i am using .net.

    However, i have now used simple Array to declare each point to make it simple.

    irfan

  6. #6
    Paul Richardson Guest
    Your Welcome...

    No control arrays either...I hate that..;) And it's work
    arounds...
    "irfan" <nospam@address.withheld> wrote in message
    news:24561275.1102947625296.JavaMail.jive@jiveforu m1.autodesk.com...
    thanks paul and DRW for ur suggestions
    Cant use Variant, as i am using .net.

    However, i have now used simple Array to declare each point to make it
    simple.

    irfan

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

    DRW

  8. #8
    Nathan Taylor Guest
    Your NewPoint was a three element array of doubles. NewPoint(0) would have been the X Value, NewPoint(1) would have been the Y Value & NewPoint(2) would have been the Z Value.
    Regards - Nathan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum