Points and properties of objects

Points and properties of objects

Anonymous
Not applicable
428 Views
15 Replies
Message 1 of 16

Points and properties of objects

Anonymous
Not applicable
Howdy Ya'll (sorry couldn't resist!)

I am trying to get a point (Pt1) on a line by allowing the user to select
the point (first line of code). I have set "OSMODE" to nearest as the exact
point does not matter as long as it falls on the line. I also need to get
the properties of the line with the point on it (Ln2), so I have the user
select that same line again (second line of code). I would rather not have
to use two user picks to achieve this. I have tried to use one line of code
(third line of code below) but sometimes the point does not fall on the line
and this will just not do. Is there a way to only have one user pick to get
the point (Pt1) on the line and get the properties of the line (Ln2)?

Pt1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "Select the opening start
point: ")
ThisDrawing.Utility.GetEntity Ln2, ptNothing, "Select the same wall: "

ThisDrawing.Utility.GetEntity Ln2, Pt1, "Select the opening start point: "

Thanx,

Rob
0 Likes
429 Views
15 Replies
Replies (15)
Message 2 of 16

Anonymous
Not applicable
If OSMode is bit-coded to "Nea" why don't you just use ptNothing?

--
http://www.acadx.com


"Rob Outman" wrote in message
news:BD7DC9FBBAC6D7516CF310AE3BA88781@in.WebX.maYIadrTaRb...
| Howdy Ya'll (sorry couldn't resist!)
|
| I am trying to get a point (Pt1) on a line by allowing the user to select
| the point (first line of code). I have set "OSMODE" to nearest as the
exact
| point does not matter as long as it falls on the line. I also need to get
| the properties of the line with the point on it (Ln2), so I have the user
| select that same line again (second line of code). I would rather not have
| to use two user picks to achieve this. I have tried to use one line of
code
| (third line of code below) but sometimes the point does not fall on the
line
| and this will just not do. Is there a way to only have one user pick to
get
| the point (Pt1) on the line and get the properties of the line (Ln2)?
|
| Pt1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "Select the opening start
| point: ")
| ThisDrawing.Utility.GetEntity Ln2, ptNothing, "Select the same wall: "
|
| ThisDrawing.Utility.GetEntity Ln2, Pt1, "Select the opening start point: "
|
| Thanx,
|
| Rob
|
|
0 Likes
Message 3 of 16

Anonymous
Not applicable
It appears to me that the osnaps do not work while using the GetEntity
method... at least I don't get any! I only get the osnaps when I use the
GetPoint method.

Rob

"R. Robert Bell" wrote in message
news:ED38A93BAB30C66E08C4D4D564545FBF@in.WebX.maYIadrTaRb...
> If OSMode is bit-coded to "Nea" why don't you just use ptNothing?
>
> --
> http://www.acadx.com
>
>
> "Rob Outman" wrote in message
> news:BD7DC9FBBAC6D7516CF310AE3BA88781@in.WebX.maYIadrTaRb...
> | Howdy Ya'll (sorry couldn't resist!)
> |
> | I am trying to get a point (Pt1) on a line by allowing the user to
select
> | the point (first line of code). I have set "OSMODE" to nearest as the
> exact
> | point does not matter as long as it falls on the line. I also need to
get
> | the properties of the line with the point on it (Ln2), so I have the
user
> | select that same line again (second line of code). I would rather not
have
> | to use two user picks to achieve this. I have tried to use one line of
> code
> | (third line of code below) but sometimes the point does not fall on the
> line
> | and this will just not do. Is there a way to only have one user pick to
> get
> | the point (Pt1) on the line and get the properties of the line (Ln2)?
> |
> | Pt1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "Select the opening start
> | point: ")
> | ThisDrawing.Utility.GetEntity Ln2, ptNothing, "Select the same wall: "
> |
> | ThisDrawing.Utility.GetEntity Ln2, Pt1, "Select the opening start point:
"
> |
> | Thanx,
> |
> | Rob
> |
> |
>
>
0 Likes
Message 4 of 16

Anonymous
Not applicable
Ok, this thing does 2 things i don't like to do... use the user variables
within autocad (because i don't know if others are using them to save
settings for their own programs) and the "SendCommand" (with lisp within
it -- yeeeeach) -- but hey, it gets the job done. The
"GetWallAndNearestPoint" function requires you to feed by reference a
variable for your wall line, and a variable for your "nearest point" and
when its done, those to variables should have the info you need.

Public Function Distance _
(ByVal Point1 As Variant, _
ByVal Point2 As Variant) _
As Double

Dim XDir As Double
Dim YDir As Double

XDir = Abs(Point1(0) - Point2(0))
YDir = Abs(Point1(1) - Point2(1))

Distance = Abs(Sqr((XDir * XDir) + (YDir * YDir)))
End Function

'This will return an endpoint of a line entity, or nothing on error
Public Function GetWallAndNearestPoint(objWall As AcadLine, NearestPoint As
Variant) As Variant
Dim obj As Object
Dim pt As Variant

'Get the object and the point the user picked
ThisDrawing.Utility.GetEntity obj, pt, _
vbCrLf & "Select wall near an end..."

'If its a line, compare where the user picked the line _
to the endpoints and return the closer of the two
If TypeOf obj Is AcadLine Then
Set objWall = obj

'This just turns the variable into a "point array"
NearestPoint = pt

'Get the point...
With ThisDrawing
.SetVariable "lastpoint", pt
.SendCommand ("(setq TempPoint (osnap (getvar ""lastpoint"")
""_nea""))" & vbCr)
.SendCommand ("(setvar ""userr4"" (car TempPoint))" & vbCr)
NearestPoint(0) = .GetVariable("userr4")
.SendCommand ("(setvar ""userr4"" (cadr TempPoint))" & vbCr)
NearestPoint(1) = .GetVariable("userr4")
.SendCommand ("(setvar ""userr4"" (caddr TempPoint))" & vbCr)
NearestPoint(2) = .GetVariable("userr4")
End With
End If
End Function
0 Likes
Message 5 of 16

Anonymous
Not applicable
Use the GetClosestPointTo method of Curve.cls. Feed it the point
returned by GetEntity and it will return a point that is actually *on*
the line.

--
http://www.acadx.com


"Rob Outman" wrote in message
news:BD7DC9FBBAC6D7516CF310AE3BA88781@in.WebX.maYIadrTaRb...
> Howdy Ya'll (sorry couldn't resist!)
0 Likes
Message 6 of 16

Anonymous
Not applicable
...oops -- i guess i didn't need to include that "Distance" function....
when i was writing it, i was going in another direction of comparing the
point picked and seeing which end was closer.
0 Likes
Message 7 of 16

Anonymous
Not applicable
Hi Frank,

Ok I have never worked with class modules to this point, so could you give
me a bit of background on how I would go about getting this to work? I have
the CURVE.cls and the VLAX.cls loaded intoVBA in two separate Class modules.
I am getting the following in both of the class modules to highlight red:

VERSION 1.0 CLASS

Attribute VB_Name = "Curve"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

and

VERSION 1.0 CLASS

Attribute VB_Name = "VLAX"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

The above all highlight red in the code window. Do I call the
GetClosestPointTo the same way I would in a function?

Thanx,

Rob

"Frank Oquendo" wrote in message
news:E2DF479A1CAD785BFFCD8FC44FB566BC@in.WebX.maYIadrTaRb...
> Use the GetClosestPointTo method of Curve.cls. Feed it the point
> returned by GetEntity and it will return a point that is actually *on*
> the line.
>
> --
> http://www.acadx.com
>
>
> "Rob Outman" wrote in message
> news:BD7DC9FBBAC6D7516CF310AE3BA88781@in.WebX.maYIadrTaRb...
> > Howdy Ya'll (sorry couldn't resist!)
>
>
>
0 Likes
Message 8 of 16

Anonymous
Not applicable
... and the entity selection part should say "Select the opening start
point..." -- again, left over from my first attempt.
0 Likes
Message 9 of 16

Anonymous
Not applicable
Send me a personal email (remove the NOSPAM) reminding me to post a
VBA-friendly version of VLAX. VBA modules work fine in VB but VB
modules have a lot of extra hidden code in them that VBA chikes on.
Delete all the red stuff.

As for using the GetClosestPointTo method, it's not that
straightforward. First, create a Curve object. Then set the curve's
Entity property using the entity selected by the user:

Dim c As Curve, newPt, retval(0 To 2) As Double

Set c = New Curve
Set c.Entity =
newPt = c.GetClosestPointTo()
retval(0) = newPt(0)
retval(1) = newPt(1)
retval(2) = newPt(2)

While you're emailing me, remind me to fix the GetClosestPointTo
method (and all point-related Curve function) to return a point that
won't require any massaging.

--
http://www.acadx.com


"Rob Outman" wrote in message
news:906F326DBBC6AE573A40F16C6EDB8CBD@in.WebX.maYIadrTaRb...
> Hi Frank,
>
> Ok I have never worked with class modules to this point, so could
you give
> me a bit of background on how I would go about getting this to work?
I have
> the CURVE.cls and the VLAX.cls loaded intoVBA in two separate Class
modules.
> I am getting the following in both of the class modules to highlight
red:
>
> VERSION 1.0 CLASS
>
> Attribute VB_Name = "Curve"
> Attribute VB_GlobalNameSpace = False
> Attribute VB_Creatable = False
> Attribute VB_PredeclaredId = False
> Attribute VB_Exposed = False
>
> and
>
> VERSION 1.0 CLASS
>
> Attribute VB_Name = "VLAX"
> Attribute VB_GlobalNameSpace = False
> Attribute VB_Creatable = False
> Attribute VB_PredeclaredId = False
> Attribute VB_Exposed = False
>
> The above all highlight red in the code window. Do I call the
> GetClosestPointTo the same way I would in a function?
>
> Thanx,
>
> Rob
>
> "Frank Oquendo" wrote in message
> news:E2DF479A1CAD785BFFCD8FC44FB566BC@in.WebX.maYIadrTaRb...
> > Use the GetClosestPointTo method of Curve.cls. Feed it the point
> > returned by GetEntity and it will return a point that is actually
*on*
> > the line.
> >
> > --
> > http://www.acadx.com
> >
> >
> > "Rob Outman" wrote in message
> > news:BD7DC9FBBAC6D7516CF310AE3BA88781@in.WebX.maYIadrTaRb...
> > > Howdy Ya'll (sorry couldn't resist!)
> >
> >
> >
>
>
0 Likes
Message 10 of 16

Anonymous
Not applicable
Hi Lanny,

That works great... although I am still intrigued by Franks Curve.cls as it
has a bunch of functionality that I could use all over. Wish me luck!

Rob

"Lanny Schiele" wrote in message
news:83014DB5EE7741C484CCE9407B55829D@in.WebX.maYIadrTaRb...
> ... and the entity selection part should say "Select the opening start
> point..." -- again, left over from my first attempt.
>
>
0 Likes
Message 11 of 16

Anonymous
Not applicable
... hey -- my code is where you (and whoever comes across it) needs the
luck -- at least Frank knows what he's doing!

"Rob Outman" wrote:
> That works great... although I am still intrigued by Franks Curve.cls as
it
> has a bunch of functionality that I could use all over. Wish me luck!
0 Likes
Message 12 of 16

Anonymous
Not applicable
Hey Frank -- for whatever reason, the applet at your website wasn't working
on my machine for quite sometime, but i visited today and it worked.
Anyway, i just wanted to see what this VLAX class was about -- WHOA! --
some cool code you got going there. I'll be using it as well as the Curve
class to get around whatever obstacles VBA presents. = )
0 Likes
Message 13 of 16

Anonymous
Not applicable
Rob, Why not just use GetEntity? Once you have the line, use either the
EndPoint property or StartPoint property to get your point, assuming it does
not matter which point was picked - forget the osnap.

Regards,
Jacob Dinardi


Rob Outman wrote in message
news:906F326DBBC6AE573A40F16C6EDB8CBD@in.WebX.maYIadrTaRb...
Hi Frank,

Ok I have never worked with class modules to this point, so could you give
me a bit of background on how I would go about getting this to work? I have
the CURVE.cls and the VLAX.cls loaded intoVBA in two separate Class modules.
I am getting the following in both of the class modules to highlight red:

VERSION 1.0 CLASS

Attribute VB_Name = "Curve"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

and

VERSION 1.0 CLASS

Attribute VB_Name = "VLAX"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

The above all highlight red in the code window. Do I call the
GetClosestPointTo the same way I would in a function?

Thanx,

Rob

"Frank Oquendo" wrote in message
news:E2DF479A1CAD785BFFCD8FC44FB566BC@in.WebX.maYIadrTaRb...
> Use the GetClosestPointTo method of Curve.cls. Feed it the point
> returned by GetEntity and it will return a point that is actually *on*
> the line.
>
> --
> http://www.acadx.com
>
>
> "Rob Outman" wrote in message
> news:BD7DC9FBBAC6D7516CF310AE3BA88781@in.WebX.maYIadrTaRb...
> > Howdy Ya'll (sorry couldn't resist!)
>
>
>
0 Likes
Message 14 of 16

Anonymous
Not applicable
Hi Jacob,

Actually, the point needs to be somewhere on the line very near to where the
user picked. With GetEntity, I have noticed that the point sometimes falls
off of the line (especially when the pickbox is large!)

Rob

"Jacob Dinardi" wrote in message
news:5E96CD0A09AFF7FEC47B346A613DE7EB@in.WebX.maYIadrTaRb...
> Rob, Why not just use GetEntity? Once you have the line, use either the
> EndPoint property or StartPoint property to get your point, assuming it
does
> not matter which point was picked - forget the osnap.
>
> Regards,
> Jacob Dinardi
>
>
> Rob Outman wrote in message
> news:906F326DBBC6AE573A40F16C6EDB8CBD@in.WebX.maYIadrTaRb...
> Hi Frank,
>
> Ok I have never worked with class modules to this point, so could you give
> me a bit of background on how I would go about getting this to work? I
have
> the CURVE.cls and the VLAX.cls loaded intoVBA in two separate Class
modules.
> I am getting the following in both of the class modules to highlight red:
>
> VERSION 1.0 CLASS
>
> Attribute VB_Name = "Curve"
> Attribute VB_GlobalNameSpace = False
> Attribute VB_Creatable = False
> Attribute VB_PredeclaredId = False
> Attribute VB_Exposed = False
>
> and
>
> VERSION 1.0 CLASS
>
> Attribute VB_Name = "VLAX"
> Attribute VB_GlobalNameSpace = False
> Attribute VB_Creatable = False
> Attribute VB_PredeclaredId = False
> Attribute VB_Exposed = False
>
> The above all highlight red in the code window. Do I call the
> GetClosestPointTo the same way I would in a function?
>
> Thanx,
>
> Rob
>
> "Frank Oquendo" wrote in message
> news:E2DF479A1CAD785BFFCD8FC44FB566BC@in.WebX.maYIadrTaRb...
> > Use the GetClosestPointTo method of Curve.cls. Feed it the point
> > returned by GetEntity and it will return a point that is actually *on*
> > the line.
> >
> > --
> > http://www.acadx.com
> >
> >
> > "Rob Outman" wrote in message
> > news:BD7DC9FBBAC6D7516CF310AE3BA88781@in.WebX.maYIadrTaRb...
> > > Howdy Ya'll (sorry couldn't resist!)
> >
> >
> >
>
>
>
>
0 Likes
Message 15 of 16

Anonymous
Not applicable
Instead of using the point returned by the function, use a property of the
line. What are you doing with this point anyway? I remember it from your
routine the other day - I thought it was strange that nearest was locked up.

JD

Rob Outman wrote in message
news:B98D80C31F1E967CBBE70BE14DA72CFC@in.WebX.maYIadrTaRb...
Hi Jacob,

Actually, the point needs to be somewhere on the line very near to where the
user picked. With GetEntity, I have noticed that the point sometimes falls
off of the line (especially when the pickbox is large!)

Rob

"Jacob Dinardi" wrote in message
news:5E96CD0A09AFF7FEC47B346A613DE7EB@in.WebX.maYIadrTaRb...
> Rob, Why not just use GetEntity? Once you have the line, use either the
> EndPoint property or StartPoint property to get your point, assuming it
does
> not matter which point was picked - forget the osnap.
>
> Regards,
> Jacob Dinardi
>
>
> Rob Outman wrote in message
> news:906F326DBBC6AE573A40F16C6EDB8CBD@in.WebX.maYIadrTaRb...
> Hi Frank,
>
> Ok I have never worked with class modules to this point, so could you give
> me a bit of background on how I would go about getting this to work? I
have
> the CURVE.cls and the VLAX.cls loaded intoVBA in two separate Class
modules.
> I am getting the following in both of the class modules to highlight red:
>
> VERSION 1.0 CLASS
>
> Attribute VB_Name = "Curve"
> Attribute VB_GlobalNameSpace = False
> Attribute VB_Creatable = False
> Attribute VB_PredeclaredId = False
> Attribute VB_Exposed = False
>
> and
>
> VERSION 1.0 CLASS
>
> Attribute VB_Name = "VLAX"
> Attribute VB_GlobalNameSpace = False
> Attribute VB_Creatable = False
> Attribute VB_PredeclaredId = False
> Attribute VB_Exposed = False
>
> The above all highlight red in the code window. Do I call the
> GetClosestPointTo the same way I would in a function?
>
> Thanx,
>
> Rob
>
> "Frank Oquendo" wrote in message
> news:E2DF479A1CAD785BFFCD8FC44FB566BC@in.WebX.maYIadrTaRb...
> > Use the GetClosestPointTo method of Curve.cls. Feed it the point
> > returned by GetEntity and it will return a point that is actually *on*
> > the line.
> >
> > --
> > http://www.acadx.com
> >
> >
> > "Rob Outman" wrote in message
> > news:BD7DC9FBBAC6D7516CF310AE3BA88781@in.WebX.maYIadrTaRb...
> > > Howdy Ya'll (sorry couldn't resist!)
> >
> >
> >
>
>
>
>
0 Likes
Message 16 of 16

Anonymous
Not applicable
Jacob,

If you remember the routine, then you probably noticed that the user had to
pick the hinge point of the door and then select the same line again in
order to get the line properties. This added one more click to the routine
that I really don't think is necessary, and that the users don't like, so I
am trying to make it so the user only has to pick once for the hingepoint
instead of twice. I need the line properties in order to erase the old
lines and add the new ones. The hingepoint does not have to be at the exact
point the user selects, but it should be close. I use nearest because our
drawings do not require that much accuracy. We just place a door in a
general location. Later I will add a function to allow the user to enter a
jamb distance and actually place the door the distance entered from a
certain endpoint (if that makes sense!)

Hope that helps explain what I am trying to accomplish.

Rob

"Jacob Dinardi" wrote in message
news:5405B649F8EEBC3FF9C7E88CC5A32EE2@in.WebX.maYIadrTaRb...
> Instead of using the point returned by the function, use a property of the
> line. What are you doing with this point anyway? I remember it from your
> routine the other day - I thought it was strange that nearest was locked
up.
>
> JD
>
> Rob Outman wrote in message
> news:B98D80C31F1E967CBBE70BE14DA72CFC@in.WebX.maYIadrTaRb...
> Hi Jacob,
>
> Actually, the point needs to be somewhere on the line very near to where
the
> user picked. With GetEntity, I have noticed that the point sometimes
falls
> off of the line (especially when the pickbox is large!)
>
> Rob
>
> "Jacob Dinardi" wrote in message
> news:5E96CD0A09AFF7FEC47B346A613DE7EB@in.WebX.maYIadrTaRb...
> > Rob, Why not just use GetEntity? Once you have the line, use either the
> > EndPoint property or StartPoint property to get your point, assuming it
> does
> > not matter which point was picked - forget the osnap.
> >
> > Regards,
> > Jacob Dinardi
> >
> >
> > Rob Outman wrote in message
> > news:906F326DBBC6AE573A40F16C6EDB8CBD@in.WebX.maYIadrTaRb...
> > Hi Frank,
> >
> > Ok I have never worked with class modules to this point, so could you
give
> > me a bit of background on how I would go about getting this to work? I
> have
> > the CURVE.cls and the VLAX.cls loaded intoVBA in two separate Class
> modules.
> > I am getting the following in both of the class modules to highlight
red:
> >
> > VERSION 1.0 CLASS
> >
> > Attribute VB_Name = "Curve"
> > Attribute VB_GlobalNameSpace = False
> > Attribute VB_Creatable = False
> > Attribute VB_PredeclaredId = False
> > Attribute VB_Exposed = False
> >
> > and
> >
> > VERSION 1.0 CLASS
> >
> > Attribute VB_Name = "VLAX"
> > Attribute VB_GlobalNameSpace = False
> > Attribute VB_Creatable = False
> > Attribute VB_PredeclaredId = False
> > Attribute VB_Exposed = False
> >
> > The above all highlight red in the code window. Do I call the
> > GetClosestPointTo the same way I would in a function?
> >
> > Thanx,
> >
> > Rob
> >
> > "Frank Oquendo" wrote in message
> > news:E2DF479A1CAD785BFFCD8FC44FB566BC@in.WebX.maYIadrTaRb...
> > > Use the GetClosestPointTo method of Curve.cls. Feed it the point
> > > returned by GetEntity and it will return a point that is actually *on*
> > > the line.
> > >
> > > --
> > > http://www.acadx.com
> > >
> > >
> > > "Rob Outman" wrote in message
> > > news:BD7DC9FBBAC6D7516CF310AE3BA88781@in.WebX.maYIadrTaRb...
> > > > Howdy Ya'll (sorry couldn't resist!)
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>
0 Likes