acadPoint.cordinates

acadPoint.cordinates

Anonymous
Not applicable
2,822 Views
7 Replies
Message 1 of 8

acadPoint.cordinates

Anonymous
Not applicable
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
0 Likes
2,823 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
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
0 Likes
Message 3 of 8

Anonymous
Not applicable
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
0 Likes
Message 4 of 8

Anonymous
Not applicable
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" wrote in message news:13626397.1102937893093.JavaMail.jive@jiveforum1.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
0 Likes
Message 5 of 8

Anonymous
Not applicable
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
0 Likes
Message 6 of 8

Anonymous
Not applicable
Your Welcome... No control arrays either...I hate that..;) And it's work arounds... "irfan" wrote in message news:24561275.1102947625296.JavaMail.jive@jiveforum1.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
0 Likes
Message 7 of 8

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

DRW
0 Likes
Message 8 of 8

Anonymous
Not applicable
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
0 Likes