acadPoint.cordinates
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
acadPoint.cordinates

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
irfan
Guest





Posted: Mon Dec 13, 2004 4:37 pm    Post subject: acadPoint.cordinates Reply with quote

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

Back to top
DRW1975
Guest





Posted: Mon Dec 13, 2004 5:49 pm    Post subject: Re: acadPoint.cordinates Reply with quote

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
Back to top
DRW1975
Guest





Posted: Mon Dec 13, 2004 6:03 pm    Post subject: Re: acadPoint.cordinates Reply with quote

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

Back to top
Paul Richardson
Guest





Posted: Mon Dec 13, 2004 6:44 pm    Post subject: Re: acadPoint.cordinates Reply with quote

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@jiveforum1.autodesk.com...
Quote:
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
Back to top
irfan
Guest





Posted: Mon Dec 13, 2004 7:19 pm    Post subject: Re: acadPoint.cordinates Reply with quote

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
Back to top
Paul Richardson
Guest





Posted: Mon Dec 13, 2004 7:33 pm    Post subject: Re: acadPoint.cordinates Reply with quote

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@jiveforum1.autodesk.com...
Quote:
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
Back to top
DRW1975
Guest





Posted: Mon Dec 13, 2004 7:34 pm    Post subject: Re: acadPoint.cordinates Reply with quote

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

DRW
Back to top
Nathan Taylor
Guest





Posted: Tue Dec 14, 2004 2:43 am    Post subject: Re: acadPoint.cordinates Reply with quote

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
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB