Showing LW-PLine Length as the line is drawn

Showing LW-PLine Length as the line is drawn

Anonymous
Not applicable
465 Views
5 Replies
Message 1 of 6

Showing LW-PLine Length as the line is drawn

Anonymous
Not applicable
I am trying to create a VBA program to display total PLine length as I draw
the line. i.e.

Start the PLine command, pick a starting point.
As soon as I pick a second point I want a dialog box to come up to tell me
how long the line is up to that point.
After displaying the length, pick a third point for the PLine, and display
the new total length (not the last segment length).
Keep going, etc. till endpoint of line is created.

I've found a VB function to do the total length calculation, and created the
form in VBA to display the total length.

The problem seems to be 'Focus'. How do I change focus after displaying the
dialog so the user doesn't have to click 'OK' in the dialog every time he
picks a new point?


Miles Andrews
smilesfromnowhere at hotmail dot com
0 Likes
466 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
I'm a Delphi guy and don't know if VB implements SetForgroundWindow() from
then WinAPI. If not you can make the call directly using external calls to
WinAPI.

You'll have to find the hWnd for The drawing editor window and not the main
AutoCAD Window as it may not necessarily give focus to the user drawing the
pline.

The best way to do this would be to have a floating toolbar (modeless form)
displaying the calculated distance without having to dismiss it every time
you pick a point. How are you handling curves within the pline?

Hugo


"Hawk A. Loogie" wrote in message
news:[email protected]...
> I am trying to create a VBA program to display total PLine length as I
draw
> the line. i.e.
>
> Start the PLine command, pick a starting point.
> As soon as I pick a second point I want a dialog box to come up to tell me
> how long the line is up to that point.
> After displaying the length, pick a third point for the PLine, and display
> the new total length (not the last segment length).
> Keep going, etc. till endpoint of line is created.
>
> I've found a VB function to do the total length calculation, and created
the
> form in VBA to display the total length.
>
> The problem seems to be 'Focus'. How do I change focus after displaying
the
> dialog so the user doesn't have to click 'OK' in the dialog every time he
> picks a new point?
>
>
> Miles Andrews
> smilesfromnowhere at hotmail dot com
>
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
>The best way to do this would be to have a floating toolbar
Any ideas how I would create one of these?

Miles

"Hugo Guerrero" wrote in message
news:[email protected]...
> I'm a Delphi guy and don't know if VB implements SetForgroundWindow() from
> then WinAPI. If not you can make the call directly using external calls
to
> WinAPI.
>
> You'll have to find the hWnd for The drawing editor window and not the
main
> AutoCAD Window as it may not necessarily give focus to the user drawing
the
> pline.
>
> The best way to do this would be to have a floating toolbar (modeless
form)
> displaying the calculated distance without having to dismiss it every time
> you pick a point. How are you handling curves within the pline?
>
> Hugo
>
>
> "Hawk A. Loogie" wrote in message
> news:[email protected]...
> > I am trying to create a VBA program to display total PLine length as I
> draw
> > the line. i.e.
> >
> > Start the PLine command, pick a starting point.
> > As soon as I pick a second point I want a dialog box to come up to tell
me
> > how long the line is up to that point.
> > After displaying the length, pick a third point for the PLine, and
display
> > the new total length (not the last segment length).
> > Keep going, etc. till endpoint of line is created.
> >
> > I've found a VB function to do the total length calculation, and created
> the
> > form in VBA to display the total length.
> >
> > The problem seems to be 'Focus'. How do I change focus after displaying
> the
> > dialog so the user doesn't have to click 'OK' in the dialog every time
he
> > picks a new point?
> >
> >
> > Miles Andrews
> > smilesfromnowhere at hotmail dot com
> >
> >
>
>
0 Likes
Message 4 of 6

Anonymous
Not applicable
I suppose VBA does not let you create modeless forms within AutoCAD so it
might not be doable with VBA. Seems like you would have to use VB to build
an external ActiveX Automation Object. The best thing to do is to build it
with ObjectARX and MFC. I can do it with Delphi but it is not supported by
AutoCAD.


"Hawk A. Loogie" wrote in message
news:[email protected]...
> >The best way to do this would be to have a floating toolbar
> Any ideas how I would create one of these?
>
> Miles
>
> "Hugo Guerrero" wrote in message
> news:[email protected]...
> > I'm a Delphi guy and don't know if VB implements SetForgroundWindow()
from
> > then WinAPI. If not you can make the call directly using external calls
> to
> > WinAPI.
> >
> > You'll have to find the hWnd for The drawing editor window and not the
> main
> > AutoCAD Window as it may not necessarily give focus to the user drawing
> the
> > pline.
> >
> > The best way to do this would be to have a floating toolbar (modeless
> form)
> > displaying the calculated distance without having to dismiss it every
time
> > you pick a point. How are you handling curves within the pline?
> >
> > Hugo
> >
> >
> > "Hawk A. Loogie" wrote in message
> > news:[email protected]...
> > > I am trying to create a VBA program to display total PLine length as I
> > draw
> > > the line. i.e.
> > >
> > > Start the PLine command, pick a starting point.
> > > As soon as I pick a second point I want a dialog box to come up to
tell
> me
> > > how long the line is up to that point.
> > > After displaying the length, pick a third point for the PLine, and
> display
> > > the new total length (not the last segment length).
> > > Keep going, etc. till endpoint of line is created.
> > >
> > > I've found a VB function to do the total length calculation, and
created
> > the
> > > form in VBA to display the total length.
> > >
> > > The problem seems to be 'Focus'. How do I change focus after
displaying
> > the
> > > dialog so the user doesn't have to click 'OK' in the dialog every time
> he
> > > picks a new point?
> > >
> > >
> > > Miles Andrews
> > > smilesfromnowhere at hotmail dot com
> > >
> > >
> >
> >
>
>
0 Likes
Message 5 of 6

Anonymous
Not applicable
Yes, VBA allows modeless dialogs and yes you can implement [almost] any API you want in VBA. However, you will need to be using 2000i or higher.


UserForm1.Show vbModeless
0 Likes
Message 6 of 6

Anonymous
Not applicable
(My lost reply from January 12 2003)



Instead of using a dialog, Show a modeless UserForm. You will have to explicity Close it when the user has finished drawing the line.



Now you can either have the UserForm displaying all the time, but probably you only want it to appear when the user starts drawing a line. So you may have the issue of changing the focus back to the drawing after initially Showing the UserForm. I haven't tried it but you could investigate the Activate method. Failing that you could investigate using the Windows API SetFocus. Note that this is different from (and may conflict with) the VB/VBA SetFocus method, so you should rename it as follows:


Declare Function SetFocusAPI Lib "User32" Alias "SetFocus" (ByVal hWnd As Long) As Long

Good luck, and please consider posting your final solution back here for all to enjoy!



Wayne Ivory

IT Analyst Programmer

Wespine Industries Pty Ltd
0 Likes