object re-selection

object re-selection

Anonymous
Not applicable
628 Views
16 Replies
Message 1 of 17

object re-selection

Anonymous
Not applicable
This is probably staring me in the face, but ...

I have a routine that prompts the user for an entity, and if this entity is
not a closed polyline, then it attempts to make it one for the user. All of
this works fine, my problem is in the retest. I can't seem to reselect the
(now a polyline) entity within the code (i.e. without user interaction). I
obtain the original entity with ThisDrawing.Utility.GetEntity and then
create the polyline with sendcommand.

Any help would be appreciated.
0 Likes
629 Views
16 Replies
Replies (16)
Message 2 of 17

Anonymous
Not applicable
if this is exactly what you're doing...
> I have a routine that prompts the user for *an* entity, and if this entity
is
> not a closed polyline, then it attempts to make *it* one for the user.
meaning you're only dealing with one entity at a time, why are you using
sendcommand to create the pline.
if you're using vba, why not use vba?
if it's already a pline and you just want to close it, you just have to set
it's closed property
if it's not a pline, you could create a pline with AddLightweightpolyline
in which case you'd have the newly created object available

on the other hand if you prefer sendcommand, then (entlast) should give you
the just added pline (if it's visible in your current display window)

"Nathan Guill" wrote in message
news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> This is probably staring me in the face, but ...
>
> I have a routine that prompts the user for an entity, and if this entity
is
> not a closed polyline, then it attempts to make it one for the user. All
of
> this works fine, my problem is in the retest. I can't seem to reselect
the
> (now a polyline) entity within the code (i.e. without user interaction). I
> obtain the original entity with ThisDrawing.Utility.GetEntity and then
> create the polyline with sendcommand.
>
> Any help would be appreciated.
>
>
0 Likes
Message 3 of 17

Anonymous
Not applicable
If you just created an entity, it will be the last in the db. Just like you
can use the Last argument to any selection prompt in acad, the selection set
object has this option too.
Dim ss As AcadSelectionSet
ss.Select acSelectionSetLast

--
--
Ed
--
"Nathan Guill" wrote in message
news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> This is probably staring me in the face, but ...
>
> I have a routine that prompts the user for an entity, and if this entity
is
> not a closed polyline, then it attempts to make it one for the user. All
of
> this works fine, my problem is in the retest. I can't seem to reselect
the
> (now a polyline) entity within the code (i.e. without user interaction). I
> obtain the original entity with ThisDrawing.Utility.GetEntity and then
> create the polyline with sendcommand.
>
> Any help would be appreciated.
>
>
0 Likes
Message 4 of 17

Anonymous
Not applicable
What's happening is that the user selects an entity, if this entity is a
LWPolyline, then it checks to see if it's closed. If the pline is not
closed, or the entity is not a pline, then it attamps to "Join All" the
entities connected to it to see if that creates a closed pline. IF so, then
I can continue with the rest of my routine, which is to revolve the closed
pline to get the volume and eventually the weight of the cross section the
user first selected.

"Mark Propst" wrote in message
news:51AFF249F18808087279B396951C3454@in.WebX.maYIadrTaRb...
> if this is exactly what you're doing...
> > I have a routine that prompts the user for *an* entity, and if this
entity
> is
> > not a closed polyline, then it attempts to make *it* one for the user.
> meaning you're only dealing with one entity at a time, why are you using
> sendcommand to create the pline.
> if you're using vba, why not use vba?
> if it's already a pline and you just want to close it, you just have to
set
> it's closed property
> if it's not a pline, you could create a pline with AddLightweightpolyline
> in which case you'd have the newly created object available
>
> on the other hand if you prefer sendcommand, then (entlast) should give
you
> the just added pline (if it's visible in your current display window)
>
> "Nathan Guill" wrote in message
> news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > This is probably staring me in the face, but ...
> >
> > I have a routine that prompts the user for an entity, and if this entity
> is
> > not a closed polyline, then it attempts to make it one for the user.
All
> of
> > this works fine, my problem is in the retest. I can't seem to reselect
> the
> > (now a polyline) entity within the code (i.e. without user interaction).
I
> > obtain the original entity with ThisDrawing.Utility.GetEntity and then
> > create the polyline with sendcommand.
> >
> > Any help would be appreciated.
> >
> >
>
>
0 Likes
Message 5 of 17

Anonymous
Not applicable
Basically, I just "joined all" the connected entities to the one the user
selected to create the pline.

select doesn't return anything, though.

Below is the code I have so far. To set it up, just create a rectangle (not
crossing the X plane) and explode it.

Function GetWeight()
Dim basePnt As Variant
Dim centerObj As AcadObject
Dim strCenter As String
Dim strWeight As String
Dim Response As VbMsgBoxResult
Dim returnObj As AcadObject
Dim ss As AcadSelectionSet

ThisDrawing.Utility.InitializeUserInput 1, "Yes No"

' Prompt the user to input any of the keywords.
strWeight = ThisDrawing.Utility.GetKeyword("Are you looking for the weight
(Yes No):")

ThisDrawing.Utility.InitializeUserInput 8
Start:
ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select cross-section
for calculation: "

If Not TypeOf returnObj Is AcadLWPolyline Then
If Len(returnObj.Handle) = 0 Then
VBA.MsgBox "You must select an entity to continue.", vbExclamation +
vbOKOnly, _
"No Entity"
GoTo Start
End If
Response = VBA.MsgBox("This entity is not a polyline," & VBA.vbCrLf & _
"Should I try and make it one?", vbQuestion + vbYesNo, "Wrong Entity
Type")

If Response = vbNo Then End

ThisDrawing.SendCommand "pedit" & VBA.vbCr & Ent2lspEnt(returnObj) & _
VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr & "All" & VBA.vbCr &
VBA.vbCr & _
VBA.vbCr

ss.Select acSelectionSetLast
'returnObj = ThisDrawing.SendCommand("(entlast)")

If Not TypeOf returnObj Is AcadLWPolyline Then
VBA.MsgBox "This entity cannot be made into a Polyline.",
vbExclamation + vbOKOnly, _
"Wrong Entity Type"
End
End If
End If

ThisDrawing.Utility.InitializeUserInput 1, "Xaxis Yaxis Object"

' Prompt the user to input any of the keywords.
strCenter = ThisDrawing.Utility.GetKeyword("Select center line (Xaxis
Yaxis Object):")

ThisDrawing.Utility.InitializeUserInput 8

Select Case strCenter
Case "Xaxis"
ThisDrawing.SendCommand "undo mark revolve " & _
FMI_Utilities.FMI.Ent2lspEnt(returnObj) & " X 360 "
Case "Yaxis"
Case "Object"
ThisDrawing.Utility.GetEntity centerObj, basePnt, "Select center line
object: "
Case Else
End
End Select

ThisDrawing.Utility.GetEntity returnObj, basePnt

If strWeight = "Yes" Then
VBA.MsgBox "This part weighs " & (returnObj.Volume * 0.297) & " in Inco
718"
Else
VBA.MsgBox "The volume of this part is " & returnObj.Volume
End If
End Function

Public Function Ent2lspEnt(entObj As AcadEntity) As String
'Designed to work with SendCommand, which can't pass objects.
'This gets an objects handle and converts it to a string
'of lisp commands that returns an entity name when run in SendCommand.
Dim entHandle As String
entHandle = entObj.Handle
Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function

"Ed Jobe" wrote in message
news:1FE06E944FA26D430C181796A59B2F14@in.WebX.maYIadrTaRb...
> If you just created an entity, it will be the last in the db. Just like
you
> can use the Last argument to any selection prompt in acad, the selection
set
> object has this option too.
> Dim ss As AcadSelectionSet
> ss.Select acSelectionSetLast
>
> --
> --
> Ed
> --
> "Nathan Guill" wrote in message
> news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > This is probably staring me in the face, but ...
> >
> > I have a routine that prompts the user for an entity, and if this entity
> is
> > not a closed polyline, then it attempts to make it one for the user.
All
> of
> > this works fine, my problem is in the retest. I can't seem to reselect
> the
> > (now a polyline) entity within the code (i.e. without user interaction).
I
> > obtain the original entity with ThisDrawing.Utility.GetEntity and then
> > create the polyline with sendcommand.
> >
> > Any help would be appreciated.
> >
> >
>
>
0 Likes
Message 6 of 17

Anonymous
Not applicable
I'm leaving pretty quick, so I don't have time to give more detail, but
SendCommand is asyncronous. It is completing after you look for the last
ent. Also, you Dim'ed ss, but didn't create an ss. You might also search
this ng on how to make a poly line. That's been discussed before. Get that
info and go with Mark's suggestion to create the poly via ActiveX. Then you
can forget the ss route and SendCommand.

--
--
Ed
--
"Nathan Guill" wrote in message
news:588D9043A9B0E48EB7EB8D4175E4E7CB@in.WebX.maYIadrTaRb...
> Basically, I just "joined all" the connected entities to the one the user
> selected to create the pline.
>
> select doesn't return anything, though.
>
> Below is the code I have so far. To set it up, just create a rectangle
(not
> crossing the X plane) and explode it.
>
> Function GetWeight()
> Dim basePnt As Variant
> Dim centerObj As AcadObject
> Dim strCenter As String
> Dim strWeight As String
> Dim Response As VbMsgBoxResult
> Dim returnObj As AcadObject
> Dim ss As AcadSelectionSet
>
> ThisDrawing.Utility.InitializeUserInput 1, "Yes No"
>
> ' Prompt the user to input any of the keywords.
> strWeight = ThisDrawing.Utility.GetKeyword("Are you looking for the
weight
> (Yes No):")
>
> ThisDrawing.Utility.InitializeUserInput 8
> Start:
> ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select cross-section
> for calculation: "
>
> If Not TypeOf returnObj Is AcadLWPolyline Then
> If Len(returnObj.Handle) = 0 Then
> VBA.MsgBox "You must select an entity to continue.", vbExclamation +
> vbOKOnly, _
> "No Entity"
> GoTo Start
> End If
> Response = VBA.MsgBox("This entity is not a polyline," & VBA.vbCrLf &
_
> "Should I try and make it one?", vbQuestion + vbYesNo, "Wrong Entity
> Type")
>
> If Response = vbNo Then End
>
> ThisDrawing.SendCommand "pedit" & VBA.vbCr & Ent2lspEnt(returnObj) & _
> VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr & "All" & VBA.vbCr &
> VBA.vbCr & _
> VBA.vbCr
>
> ss.Select acSelectionSetLast
> 'returnObj = ThisDrawing.SendCommand("(entlast)")
>
> If Not TypeOf returnObj Is AcadLWPolyline Then
> VBA.MsgBox "This entity cannot be made into a Polyline.",
> vbExclamation + vbOKOnly, _
> "Wrong Entity Type"
> End
> End If
> End If
>
> ThisDrawing.Utility.InitializeUserInput 1, "Xaxis Yaxis Object"
>
> ' Prompt the user to input any of the keywords.
> strCenter = ThisDrawing.Utility.GetKeyword("Select center line (Xaxis
> Yaxis Object):")
>
> ThisDrawing.Utility.InitializeUserInput 8
>
> Select Case strCenter
> Case "Xaxis"
> ThisDrawing.SendCommand "undo mark revolve " & _
> FMI_Utilities.FMI.Ent2lspEnt(returnObj) & " X 360 "
> Case "Yaxis"
> Case "Object"
> ThisDrawing.Utility.GetEntity centerObj, basePnt, "Select center
line
> object: "
> Case Else
> End
> End Select
>
> ThisDrawing.Utility.GetEntity returnObj, basePnt
>
> If strWeight = "Yes" Then
> VBA.MsgBox "This part weighs " & (returnObj.Volume * 0.297) & " in
Inco
> 718"
> Else
> VBA.MsgBox "The volume of this part is " & returnObj.Volume
> End If
> End Function
>
> Public Function Ent2lspEnt(entObj As AcadEntity) As String
> 'Designed to work with SendCommand, which can't pass objects.
> 'This gets an objects handle and converts it to a string
> 'of lisp commands that returns an entity name when run in SendCommand.
> Dim entHandle As String
> entHandle = entObj.Handle
> Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
> End Function
>
> "Ed Jobe" wrote in message
> news:1FE06E944FA26D430C181796A59B2F14@in.WebX.maYIadrTaRb...
> > If you just created an entity, it will be the last in the db. Just like
> you
> > can use the Last argument to any selection prompt in acad, the selection
> set
> > object has this option too.
> > Dim ss As AcadSelectionSet
> > ss.Select acSelectionSetLast
> >
> > --
> > --
> > Ed
> > --
> > "Nathan Guill" wrote in message
> > news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > > This is probably staring me in the face, but ...
> > >
> > > I have a routine that prompts the user for an entity, and if this
entity
> > is
> > > not a closed polyline, then it attempts to make it one for the user.
> All
> > of
> > > this works fine, my problem is in the retest. I can't seem to
reselect
> > the
> > > (now a polyline) entity within the code (i.e. without user
interaction).
> I
> > > obtain the original entity with ThisDrawing.Utility.GetEntity and then
> > > create the polyline with sendcommand.
> > >
> > > Any help would be appreciated.
> > >
> > >
> >
> >
>
>
0 Likes
Message 7 of 17

Anonymous
Not applicable
Something else just occured to me. At the point you check for a pline, you
only have one ent. You can't make a closed pline with one ent. You'll have
to rethink your program logic. Do you offer to make a pline at all, or just
restrict input to plines? If yes to convert to plines, you'll have to
reselect to allow multiple ents.

--
--
Ed
--
"Ed Jobe" wrote in message
news:4386729F4AA191283425321602C138FA@in.WebX.maYIadrTaRb...
> I'm leaving pretty quick, so I don't have time to give more detail, but
> SendCommand is asyncronous. It is completing after you look for the last
> ent. Also, you Dim'ed ss, but didn't create an ss. You might also search
> this ng on how to make a poly line. That's been discussed before. Get that
> info and go with Mark's suggestion to create the poly via ActiveX. Then
you
> can forget the ss route and SendCommand.
>
> --
> --
> Ed
> --
> "Nathan Guill" wrote in message
> news:588D9043A9B0E48EB7EB8D4175E4E7CB@in.WebX.maYIadrTaRb...
> > Basically, I just "joined all" the connected entities to the one the
user
> > selected to create the pline.
> >
> > select doesn't return anything, though.
> >
> > Below is the code I have so far. To set it up, just create a rectangle
> (not
> > crossing the X plane) and explode it.
> >
> > Function GetWeight()
> > Dim basePnt As Variant
> > Dim centerObj As AcadObject
> > Dim strCenter As String
> > Dim strWeight As String
> > Dim Response As VbMsgBoxResult
> > Dim returnObj As AcadObject
> > Dim ss As AcadSelectionSet
> >
> > ThisDrawing.Utility.InitializeUserInput 1, "Yes No"
> >
> > ' Prompt the user to input any of the keywords.
> > strWeight = ThisDrawing.Utility.GetKeyword("Are you looking for the
> weight
> > (Yes No):")
> >
> > ThisDrawing.Utility.InitializeUserInput 8
> > Start:
> > ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select
cross-section
> > for calculation: "
> >
> > If Not TypeOf returnObj Is AcadLWPolyline Then
> > If Len(returnObj.Handle) = 0 Then
> > VBA.MsgBox "You must select an entity to continue.", vbExclamation
+
> > vbOKOnly, _
> > "No Entity"
> > GoTo Start
> > End If
> > Response = VBA.MsgBox("This entity is not a polyline," & VBA.vbCrLf
&
> _
> > "Should I try and make it one?", vbQuestion + vbYesNo, "Wrong
Entity
> > Type")
> >
> > If Response = vbNo Then End
> >
> > ThisDrawing.SendCommand "pedit" & VBA.vbCr & Ent2lspEnt(returnObj) &
_
> > VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr & "All" & VBA.vbCr
&
> > VBA.vbCr & _
> > VBA.vbCr
> >
> > ss.Select acSelectionSetLast
> > 'returnObj = ThisDrawing.SendCommand("(entlast)")
> >
> > If Not TypeOf returnObj Is AcadLWPolyline Then
> > VBA.MsgBox "This entity cannot be made into a Polyline.",
> > vbExclamation + vbOKOnly, _
> > "Wrong Entity Type"
> > End
> > End If
> > End If
> >
> > ThisDrawing.Utility.InitializeUserInput 1, "Xaxis Yaxis Object"
> >
> > ' Prompt the user to input any of the keywords.
> > strCenter = ThisDrawing.Utility.GetKeyword("Select center line (Xaxis
> > Yaxis Object):")
> >
> > ThisDrawing.Utility.InitializeUserInput 8
> >
> > Select Case strCenter
> > Case "Xaxis"
> > ThisDrawing.SendCommand "undo mark revolve " & _
> > FMI_Utilities.FMI.Ent2lspEnt(returnObj) & " X 360 "
> > Case "Yaxis"
> > Case "Object"
> > ThisDrawing.Utility.GetEntity centerObj, basePnt, "Select center
> line
> > object: "
> > Case Else
> > End
> > End Select
> >
> > ThisDrawing.Utility.GetEntity returnObj, basePnt
> >
> > If strWeight = "Yes" Then
> > VBA.MsgBox "This part weighs " & (returnObj.Volume * 0.297) & " in
> Inco
> > 718"
> > Else
> > VBA.MsgBox "The volume of this part is " & returnObj.Volume
> > End If
> > End Function
> >
> > Public Function Ent2lspEnt(entObj As AcadEntity) As String
> > 'Designed to work with SendCommand, which can't pass objects.
> > 'This gets an objects handle and converts it to a string
> > 'of lisp commands that returns an entity name when run in SendCommand.
> > Dim entHandle As String
> > entHandle = entObj.Handle
> > Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
> > End Function
> >
> > "Ed Jobe" wrote in message
> > news:1FE06E944FA26D430C181796A59B2F14@in.WebX.maYIadrTaRb...
> > > If you just created an entity, it will be the last in the db. Just
like
> > you
> > > can use the Last argument to any selection prompt in acad, the
selection
> > set
> > > object has this option too.
> > > Dim ss As AcadSelectionSet
> > > ss.Select acSelectionSetLast
> > >
> > > --
> > > --
> > > Ed
> > > --
> > > "Nathan Guill" wrote in message
> > > news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > > > This is probably staring me in the face, but ...
> > > >
> > > > I have a routine that prompts the user for an entity, and if this
> entity
> > > is
> > > > not a closed polyline, then it attempts to make it one for the user.
> > All
> > > of
> > > > this works fine, my problem is in the retest. I can't seem to
> reselect
> > > the
> > > > (now a polyline) entity within the code (i.e. without user
> interaction).
> > I
> > > > obtain the original entity with ThisDrawing.Utility.GetEntity and
then
> > > > create the polyline with sendcommand.
> > > >
> > > > Any help would be appreciated.
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 8 of 17

Anonymous
Not applicable
I have show a form in modless and AutoCAD always get the focus unless I
click the form.
I can not input anything to the textbox in the form.
How can I deal with it?
Thank you very much!

From Afanto.
0 Likes
Message 9 of 17

Anonymous
Not applicable
does this help?
From: "Rob Starz"
Subject: Re: Working with a modeless dialog
Date: Wednesday, February 06, 2002 3:50 PM

Go to the Toolbar, right click, click Additional Controls then check
AcFocusCtrl Class.

No add the newly added control from the toolbar to your form.

In the Initialize area add
Me.AcFocusCtrl1.KeepFocus = true

now the textbox keeps its focus.

Thanks to Rich Binning for noting this.



--
"Afanto" wrote in message
news:708533350141A0A67175751F637EA002@in.WebX.maYIadrTaRb...
> I have show a form in modless and AutoCAD always get the focus unless
I
> click the form.
> I can not input anything to the textbox in the form.
> How can I deal with it?
> Thank you very much!
>
> From Afanto.
>
>
0 Likes
Message 10 of 17

Anonymous
Not applicable
Thank you very much.

Afanto
0 Likes
Message 11 of 17

Anonymous
Not applicable
You're right. I only have one entity when I first test for a pline, hence
the "join all" operation in the sendcommand. Basically, the entity the user
will be selecting will be part of a cross-section of a ring. If it's a
closed polyline then it revolves this section and gets a weight, otherwise,
it attemps to join all connected lines into a closed polyline then gets the
weight. That's why I think I have to use the sendcommand. Do you know of
another way to join all connected lines together with only one entity
selected?


"Ed Jobe" wrote in message
news:D1FACECEECA8980641C179038F681598@in.WebX.maYIadrTaRb...
> Something else just occured to me. At the point you check for a pline, you
> only have one ent. You can't make a closed pline with one ent. You'll have
> to rethink your program logic. Do you offer to make a pline at all, or
just
> restrict input to plines? If yes to convert to plines, you'll have to
> reselect to allow multiple ents.
>
> --
> --
> Ed
> --
> "Ed Jobe" wrote in message
> news:4386729F4AA191283425321602C138FA@in.WebX.maYIadrTaRb...
> > I'm leaving pretty quick, so I don't have time to give more detail, but
> > SendCommand is asyncronous. It is completing after you look for the last
> > ent. Also, you Dim'ed ss, but didn't create an ss. You might also search
> > this ng on how to make a poly line. That's been discussed before. Get
that
> > info and go with Mark's suggestion to create the poly via ActiveX. Then
> you
> > can forget the ss route and SendCommand.
> >
> > --
> > --
> > Ed
> > --
> > "Nathan Guill" wrote in message
> > news:588D9043A9B0E48EB7EB8D4175E4E7CB@in.WebX.maYIadrTaRb...
> > > Basically, I just "joined all" the connected entities to the one the
> user
> > > selected to create the pline.
> > >
> > > select doesn't return anything, though.
> > >
> > > Below is the code I have so far. To set it up, just create a
rectangle
> > (not
> > > crossing the X plane) and explode it.
> > >
> > > Function GetWeight()
> > > Dim basePnt As Variant
> > > Dim centerObj As AcadObject
> > > Dim strCenter As String
> > > Dim strWeight As String
> > > Dim Response As VbMsgBoxResult
> > > Dim returnObj As AcadObject
> > > Dim ss As AcadSelectionSet
> > >
> > > ThisDrawing.Utility.InitializeUserInput 1, "Yes No"
> > >
> > > ' Prompt the user to input any of the keywords.
> > > strWeight = ThisDrawing.Utility.GetKeyword("Are you looking for the
> > weight
> > > (Yes No):")
> > >
> > > ThisDrawing.Utility.InitializeUserInput 8
> > > Start:
> > > ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select
> cross-section
> > > for calculation: "
> > >
> > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > If Len(returnObj.Handle) = 0 Then
> > > VBA.MsgBox "You must select an entity to continue.",
vbExclamation
> +
> > > vbOKOnly, _
> > > "No Entity"
> > > GoTo Start
> > > End If
> > > Response = VBA.MsgBox("This entity is not a polyline," &
VBA.vbCrLf
> &
> > _
> > > "Should I try and make it one?", vbQuestion + vbYesNo, "Wrong
> Entity
> > > Type")
> > >
> > > If Response = vbNo Then End
> > >
> > > ThisDrawing.SendCommand "pedit" & VBA.vbCr & Ent2lspEnt(returnObj)
&
> _
> > > VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr & "All" &
VBA.vbCr
> &
> > > VBA.vbCr & _
> > > VBA.vbCr
> > >
> > > ss.Select acSelectionSetLast
> > > 'returnObj = ThisDrawing.SendCommand("(entlast)")
> > >
> > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > VBA.MsgBox "This entity cannot be made into a Polyline.",
> > > vbExclamation + vbOKOnly, _
> > > "Wrong Entity Type"
> > > End
> > > End If
> > > End If
> > >
> > > ThisDrawing.Utility.InitializeUserInput 1, "Xaxis Yaxis Object"
> > >
> > > ' Prompt the user to input any of the keywords.
> > > strCenter = ThisDrawing.Utility.GetKeyword("Select center line
(Xaxis
> > > Yaxis Object):")
> > >
> > > ThisDrawing.Utility.InitializeUserInput 8
> > >
> > > Select Case strCenter
> > > Case "Xaxis"
> > > ThisDrawing.SendCommand "undo mark revolve " & _
> > > FMI_Utilities.FMI.Ent2lspEnt(returnObj) & " X 360 "
> > > Case "Yaxis"
> > > Case "Object"
> > > ThisDrawing.Utility.GetEntity centerObj, basePnt, "Select center
> > line
> > > object: "
> > > Case Else
> > > End
> > > End Select
> > >
> > > ThisDrawing.Utility.GetEntity returnObj, basePnt
> > >
> > > If strWeight = "Yes" Then
> > > VBA.MsgBox "This part weighs " & (returnObj.Volume * 0.297) & " in
> > Inco
> > > 718"
> > > Else
> > > VBA.MsgBox "The volume of this part is " & returnObj.Volume
> > > End If
> > > End Function
> > >
> > > Public Function Ent2lspEnt(entObj As AcadEntity) As String
> > > 'Designed to work with SendCommand, which can't pass objects.
> > > 'This gets an objects handle and converts it to a string
> > > 'of lisp commands that returns an entity name when run in
SendCommand.
> > > Dim entHandle As String
> > > entHandle = entObj.Handle
> > > Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
> > > End Function
> > >
> > > "Ed Jobe" wrote in message
> > > news:1FE06E944FA26D430C181796A59B2F14@in.WebX.maYIadrTaRb...
> > > > If you just created an entity, it will be the last in the db. Just
> like
> > > you
> > > > can use the Last argument to any selection prompt in acad, the
> selection
> > > set
> > > > object has this option too.
> > > > Dim ss As AcadSelectionSet
> > > > ss.Select acSelectionSetLast
> > > >
> > > > --
> > > > --
> > > > Ed
> > > > --
> > > > "Nathan Guill" wrote in message
> > > > news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > > > > This is probably staring me in the face, but ...
> > > > >
> > > > > I have a routine that prompts the user for an entity, and if this
> > entity
> > > > is
> > > > > not a closed polyline, then it attempts to make it one for the
user.
> > > All
> > > > of
> > > > > this works fine, my problem is in the retest. I can't seem to
> > reselect
> > > > the
> > > > > (now a polyline) entity within the code (i.e. without user
> > interaction).
> > > I
> > > > > obtain the original entity with ThisDrawing.Utility.GetEntity and
> then
> > > > > create the polyline with sendcommand.
> > > > >
> > > > > Any help would be appreciated.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 12 of 17

Anonymous
Not applicable
The PEDIT command joins connected lines, but it doesn't magically find them
for you, you have to select them. If you are going to offer this feature in
your code, at the point you determine that the single ent they selected is
not a pline (assuming its a line or arc), then you need to prompt the user
to select the rest of the ents to perform the join on. Use their geometry
info to construct a pline via ActiveX. If you want just get your command
working for now, only allow them to select plines and quit if they want to
perform the join themselves. You can add the join functionality after you
get the bulk of the command working. Check this ng for code on how to make a
pline.

--
--
Ed
--
"Nathan Guill" wrote in message
news:65471D62C2CFC09F5007D338D1F4FAB7@in.WebX.maYIadrTaRb...
> You're right. I only have one entity when I first test for a pline, hence
> the "join all" operation in the sendcommand. Basically, the entity the
user
> will be selecting will be part of a cross-section of a ring. If it's a
> closed polyline then it revolves this section and gets a weight,
otherwise,
> it attemps to join all connected lines into a closed polyline then gets
the
> weight. That's why I think I have to use the sendcommand. Do you know of
> another way to join all connected lines together with only one entity
> selected?
>
>
> "Ed Jobe" wrote in message
> news:D1FACECEECA8980641C179038F681598@in.WebX.maYIadrTaRb...
> > Something else just occured to me. At the point you check for a pline,
you
> > only have one ent. You can't make a closed pline with one ent. You'll
have
> > to rethink your program logic. Do you offer to make a pline at all, or
> just
> > restrict input to plines? If yes to convert to plines, you'll have to
> > reselect to allow multiple ents.
> >
> > --
> > --
> > Ed
> > --
> > "Ed Jobe" wrote in message
> > news:4386729F4AA191283425321602C138FA@in.WebX.maYIadrTaRb...
> > > I'm leaving pretty quick, so I don't have time to give more detail,
but
> > > SendCommand is asyncronous. It is completing after you look for the
last
> > > ent. Also, you Dim'ed ss, but didn't create an ss. You might also
search
> > > this ng on how to make a poly line. That's been discussed before. Get
> that
> > > info and go with Mark's suggestion to create the poly via ActiveX.
Then
> > you
> > > can forget the ss route and SendCommand.
> > >
> > > --
> > > --
> > > Ed
> > > --
> > > "Nathan Guill" wrote in message
> > > news:588D9043A9B0E48EB7EB8D4175E4E7CB@in.WebX.maYIadrTaRb...
> > > > Basically, I just "joined all" the connected entities to the one the
> > user
> > > > selected to create the pline.
> > > >
> > > > select doesn't return anything, though.
> > > >
> > > > Below is the code I have so far. To set it up, just create a
> rectangle
> > > (not
> > > > crossing the X plane) and explode it.
> > > >
> > > > Function GetWeight()
> > > > Dim basePnt As Variant
> > > > Dim centerObj As AcadObject
> > > > Dim strCenter As String
> > > > Dim strWeight As String
> > > > Dim Response As VbMsgBoxResult
> > > > Dim returnObj As AcadObject
> > > > Dim ss As AcadSelectionSet
> > > >
> > > > ThisDrawing.Utility.InitializeUserInput 1, "Yes No"
> > > >
> > > > ' Prompt the user to input any of the keywords.
> > > > strWeight = ThisDrawing.Utility.GetKeyword("Are you looking for
the
> > > weight
> > > > (Yes No):")
> > > >
> > > > ThisDrawing.Utility.InitializeUserInput 8
> > > > Start:
> > > > ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select
> > cross-section
> > > > for calculation: "
> > > >
> > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > If Len(returnObj.Handle) = 0 Then
> > > > VBA.MsgBox "You must select an entity to continue.",
> vbExclamation
> > +
> > > > vbOKOnly, _
> > > > "No Entity"
> > > > GoTo Start
> > > > End If
> > > > Response = VBA.MsgBox("This entity is not a polyline," &
> VBA.vbCrLf
> > &
> > > _
> > > > "Should I try and make it one?", vbQuestion + vbYesNo, "Wrong
> > Entity
> > > > Type")
> > > >
> > > > If Response = vbNo Then End
> > > >
> > > > ThisDrawing.SendCommand "pedit" & VBA.vbCr &
Ent2lspEnt(returnObj)
> &
> > _
> > > > VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr & "All" &
> VBA.vbCr
> > &
> > > > VBA.vbCr & _
> > > > VBA.vbCr
> > > >
> > > > ss.Select acSelectionSetLast
> > > > 'returnObj = ThisDrawing.SendCommand("(entlast)")
> > > >
> > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > VBA.MsgBox "This entity cannot be made into a Polyline.",
> > > > vbExclamation + vbOKOnly, _
> > > > "Wrong Entity Type"
> > > > End
> > > > End If
> > > > End If
> > > >
> > > > ThisDrawing.Utility.InitializeUserInput 1, "Xaxis Yaxis Object"
> > > >
> > > > ' Prompt the user to input any of the keywords.
> > > > strCenter = ThisDrawing.Utility.GetKeyword("Select center line
> (Xaxis
> > > > Yaxis Object):")
> > > >
> > > > ThisDrawing.Utility.InitializeUserInput 8
> > > >
> > > > Select Case strCenter
> > > > Case "Xaxis"
> > > > ThisDrawing.SendCommand "undo mark revolve " & _
> > > > FMI_Utilities.FMI.Ent2lspEnt(returnObj) & " X 360 "
> > > > Case "Yaxis"
> > > > Case "Object"
> > > > ThisDrawing.Utility.GetEntity centerObj, basePnt, "Select
center
> > > line
> > > > object: "
> > > > Case Else
> > > > End
> > > > End Select
> > > >
> > > > ThisDrawing.Utility.GetEntity returnObj, basePnt
> > > >
> > > > If strWeight = "Yes" Then
> > > > VBA.MsgBox "This part weighs " & (returnObj.Volume * 0.297) & "
in
> > > Inco
> > > > 718"
> > > > Else
> > > > VBA.MsgBox "The volume of this part is " & returnObj.Volume
> > > > End If
> > > > End Function
> > > >
> > > > Public Function Ent2lspEnt(entObj As AcadEntity) As String
> > > > 'Designed to work with SendCommand, which can't pass objects.
> > > > 'This gets an objects handle and converts it to a string
> > > > 'of lisp commands that returns an entity name when run in
> SendCommand.
> > > > Dim entHandle As String
> > > > entHandle = entObj.Handle
> > > > Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
> > > > End Function
> > > >
> > > > "Ed Jobe" wrote in message
> > > > news:1FE06E944FA26D430C181796A59B2F14@in.WebX.maYIadrTaRb...
> > > > > If you just created an entity, it will be the last in the db. Just
> > like
> > > > you
> > > > > can use the Last argument to any selection prompt in acad, the
> > selection
> > > > set
> > > > > object has this option too.
> > > > > Dim ss As AcadSelectionSet
> > > > > ss.Select acSelectionSetLast
> > > > >
> > > > > --
> > > > > --
> > > > > Ed
> > > > > --
> > > > > "Nathan Guill" wrote in message
> > > > > news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > > > > > This is probably staring me in the face, but ...
> > > > > >
> > > > > > I have a routine that prompts the user for an entity, and if
this
> > > entity
> > > > > is
> > > > > > not a closed polyline, then it attempts to make it one for the
> user.
> > > > All
> > > > > of
> > > > > > this works fine, my problem is in the retest. I can't seem to
> > > reselect
> > > > > the
> > > > > > (now a polyline) entity within the code (i.e. without user
> > > interaction).
> > > > I
> > > > > > obtain the original entity with ThisDrawing.Utility.GetEntity
and
> > then
> > > > > > create the polyline with sendcommand.
> > > > > >
> > > > > > Any help would be appreciated.
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 13 of 17

Anonymous
Not applicable
I'm sorry to tell you, but if you type PEDIT, select a line, tell it to turn
it into a pline, then select join and then type in all, any lines connected
to that first line you selected will then be joined to that line. I know
this works as I do this many times a day. I NEVER have to select more than
one line as I tell it to join ALL. Since ONLY the entities that share some
common point can be joined, autocad only joins those entities. Don't
beleive me... TRY IT.


"Ed Jobe" wrote in message
news:2690302D83BEE74598E4956B343E9FEA@in.WebX.maYIadrTaRb...
> The PEDIT command joins connected lines, but it doesn't magically find
them
> for you, you have to select them. If you are going to offer this feature
in
> your code, at the point you determine that the single ent they selected is
> not a pline (assuming its a line or arc), then you need to prompt the user
> to select the rest of the ents to perform the join on. Use their geometry
> info to construct a pline via ActiveX. If you want just get your command
> working for now, only allow them to select plines and quit if they want to
> perform the join themselves. You can add the join functionality after you
> get the bulk of the command working. Check this ng for code on how to make
a
> pline.
>
> --
> --
> Ed
> --
> "Nathan Guill" wrote in message
> news:65471D62C2CFC09F5007D338D1F4FAB7@in.WebX.maYIadrTaRb...
> > You're right. I only have one entity when I first test for a pline,
hence
> > the "join all" operation in the sendcommand. Basically, the entity the
> user
> > will be selecting will be part of a cross-section of a ring. If it's a
> > closed polyline then it revolves this section and gets a weight,
> otherwise,
> > it attemps to join all connected lines into a closed polyline then gets
> the
> > weight. That's why I think I have to use the sendcommand. Do you know
of
> > another way to join all connected lines together with only one entity
> > selected?
> >
> >
> > "Ed Jobe" wrote in message
> > news:D1FACECEECA8980641C179038F681598@in.WebX.maYIadrTaRb...
> > > Something else just occured to me. At the point you check for a pline,
> you
> > > only have one ent. You can't make a closed pline with one ent. You'll
> have
> > > to rethink your program logic. Do you offer to make a pline at all, or
> > just
> > > restrict input to plines? If yes to convert to plines, you'll have to
> > > reselect to allow multiple ents.
> > >
> > > --
> > > --
> > > Ed
> > > --
> > > "Ed Jobe" wrote in message
> > > news:4386729F4AA191283425321602C138FA@in.WebX.maYIadrTaRb...
> > > > I'm leaving pretty quick, so I don't have time to give more detail,
> but
> > > > SendCommand is asyncronous. It is completing after you look for the
> last
> > > > ent. Also, you Dim'ed ss, but didn't create an ss. You might also
> search
> > > > this ng on how to make a poly line. That's been discussed before.
Get
> > that
> > > > info and go with Mark's suggestion to create the poly via ActiveX.
> Then
> > > you
> > > > can forget the ss route and SendCommand.
> > > >
> > > > --
> > > > --
> > > > Ed
> > > > --
> > > > "Nathan Guill" wrote in message
> > > > news:588D9043A9B0E48EB7EB8D4175E4E7CB@in.WebX.maYIadrTaRb...
> > > > > Basically, I just "joined all" the connected entities to the one
the
> > > user
> > > > > selected to create the pline.
> > > > >
> > > > > select doesn't return anything, though.
> > > > >
> > > > > Below is the code I have so far. To set it up, just create a
> > rectangle
> > > > (not
> > > > > crossing the X plane) and explode it.
> > > > >
> > > > > Function GetWeight()
> > > > > Dim basePnt As Variant
> > > > > Dim centerObj As AcadObject
> > > > > Dim strCenter As String
> > > > > Dim strWeight As String
> > > > > Dim Response As VbMsgBoxResult
> > > > > Dim returnObj As AcadObject
> > > > > Dim ss As AcadSelectionSet
> > > > >
> > > > > ThisDrawing.Utility.InitializeUserInput 1, "Yes No"
> > > > >
> > > > > ' Prompt the user to input any of the keywords.
> > > > > strWeight = ThisDrawing.Utility.GetKeyword("Are you looking for
> the
> > > > weight
> > > > > (Yes No):")
> > > > >
> > > > > ThisDrawing.Utility.InitializeUserInput 8
> > > > > Start:
> > > > > ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select
> > > cross-section
> > > > > for calculation: "
> > > > >
> > > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > > If Len(returnObj.Handle) = 0 Then
> > > > > VBA.MsgBox "You must select an entity to continue.",
> > vbExclamation
> > > +
> > > > > vbOKOnly, _
> > > > > "No Entity"
> > > > > GoTo Start
> > > > > End If
> > > > > Response = VBA.MsgBox("This entity is not a polyline," &
> > VBA.vbCrLf
> > > &
> > > > _
> > > > > "Should I try and make it one?", vbQuestion + vbYesNo,
"Wrong
> > > Entity
> > > > > Type")
> > > > >
> > > > > If Response = vbNo Then End
> > > > >
> > > > > ThisDrawing.SendCommand "pedit" & VBA.vbCr &
> Ent2lspEnt(returnObj)
> > &
> > > _
> > > > > VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr & "All" &
> > VBA.vbCr
> > > &
> > > > > VBA.vbCr & _
> > > > > VBA.vbCr
> > > > >
> > > > > ss.Select acSelectionSetLast
> > > > > 'returnObj = ThisDrawing.SendCommand("(entlast)")
> > > > >
> > > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > > VBA.MsgBox "This entity cannot be made into a Polyline.",
> > > > > vbExclamation + vbOKOnly, _
> > > > > "Wrong Entity Type"
> > > > > End
> > > > > End If
> > > > > End If
> > > > >
> > > > > ThisDrawing.Utility.InitializeUserInput 1, "Xaxis Yaxis Object"
> > > > >
> > > > > ' Prompt the user to input any of the keywords.
> > > > > strCenter = ThisDrawing.Utility.GetKeyword("Select center line
> > (Xaxis
> > > > > Yaxis Object):")
> > > > >
> > > > > ThisDrawing.Utility.InitializeUserInput 8
> > > > >
> > > > > Select Case strCenter
> > > > > Case "Xaxis"
> > > > > ThisDrawing.SendCommand "undo mark revolve " & _
> > > > > FMI_Utilities.FMI.Ent2lspEnt(returnObj) & " X 360 "
> > > > > Case "Yaxis"
> > > > > Case "Object"
> > > > > ThisDrawing.Utility.GetEntity centerObj, basePnt, "Select
> center
> > > > line
> > > > > object: "
> > > > > Case Else
> > > > > End
> > > > > End Select
> > > > >
> > > > > ThisDrawing.Utility.GetEntity returnObj, basePnt
> > > > >
> > > > > If strWeight = "Yes" Then
> > > > > VBA.MsgBox "This part weighs " & (returnObj.Volume * 0.297) &
"
> in
> > > > Inco
> > > > > 718"
> > > > > Else
> > > > > VBA.MsgBox "The volume of this part is " & returnObj.Volume
> > > > > End If
> > > > > End Function
> > > > >
> > > > > Public Function Ent2lspEnt(entObj As AcadEntity) As String
> > > > > 'Designed to work with SendCommand, which can't pass objects.
> > > > > 'This gets an objects handle and converts it to a string
> > > > > 'of lisp commands that returns an entity name when run in
> > SendCommand.
> > > > > Dim entHandle As String
> > > > > entHandle = entObj.Handle
> > > > > Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
> > > > > End Function
> > > > >
> > > > > "Ed Jobe" wrote in message
> > > > > news:1FE06E944FA26D430C181796A59B2F14@in.WebX.maYIadrTaRb...
> > > > > > If you just created an entity, it will be the last in the db.
Just
> > > like
> > > > > you
> > > > > > can use the Last argument to any selection prompt in acad, the
> > > selection
> > > > > set
> > > > > > object has this option too.
> > > > > > Dim ss As AcadSelectionSet
> > > > > > ss.Select acSelectionSetLast
> > > > > >
> > > > > > --
> > > > > > --
> > > > > > Ed
> > > > > > --
> > > > > > "Nathan Guill" wrote in message
> > > > > > news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > > > > > > This is probably staring me in the face, but ...
> > > > > > >
> > > > > > > I have a routine that prompts the user for an entity, and if
> this
> > > > entity
> > > > > > is
> > > > > > > not a closed polyline, then it attempts to make it one for the
> > user.
> > > > > All
> > > > > > of
> > > > > > > this works fine, my problem is in the retest. I can't seem to
> > > > reselect
> > > > > > the
> > > > > > > (now a polyline) entity within the code (i.e. without user
> > > > interaction).
> > > > > I
> > > > > > > obtain the original entity with ThisDrawing.Utility.GetEntity
> and
> > > then
> > > > > > > create the polyline with sendcommand.
> > > > > > >
> > > > > > > Any help would be appreciated.
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 14 of 17

Anonymous
Not applicable
That's true. I forgot they added that, it didn't used to do that. I havn't
used it in a while. But in the context of this discussion, you still had go
through the extra step of telling it to add more ents. The command just
filtered out all the lines that connect to it. You need to duplicate that
using ActiveX if you aren't going to use SendCommand.

--
--
Ed
--
"Nathan Guill" wrote in message
news:BF22288999FE458D9E3773E64A58E215@in.WebX.maYIadrTaRb...
> I'm sorry to tell you, but if you type PEDIT, select a line, tell it to
turn
> it into a pline, then select join and then type in all, any lines
connected
> to that first line you selected will then be joined to that line. I know
> this works as I do this many times a day. I NEVER have to select more
than
> one line as I tell it to join ALL. Since ONLY the entities that share
some
> common point can be joined, autocad only joins those entities. Don't
> beleive me... TRY IT.
>
>
> "Ed Jobe" wrote in message
> news:2690302D83BEE74598E4956B343E9FEA@in.WebX.maYIadrTaRb...
> > The PEDIT command joins connected lines, but it doesn't magically find
> them
> > for you, you have to select them. If you are going to offer this feature
> in
> > your code, at the point you determine that the single ent they selected
is
> > not a pline (assuming its a line or arc), then you need to prompt the
user
> > to select the rest of the ents to perform the join on. Use their
geometry
> > info to construct a pline via ActiveX. If you want just get your command
> > working for now, only allow them to select plines and quit if they want
to
> > perform the join themselves. You can add the join functionality after
you
> > get the bulk of the command working. Check this ng for code on how to
make
> a
> > pline.
> >
> > --
> > --
> > Ed
> > --
> > "Nathan Guill" wrote in message
> > news:65471D62C2CFC09F5007D338D1F4FAB7@in.WebX.maYIadrTaRb...
> > > You're right. I only have one entity when I first test for a pline,
> hence
> > > the "join all" operation in the sendcommand. Basically, the entity
the
> > user
> > > will be selecting will be part of a cross-section of a ring. If it's
a
> > > closed polyline then it revolves this section and gets a weight,
> > otherwise,
> > > it attemps to join all connected lines into a closed polyline then
gets
> > the
> > > weight. That's why I think I have to use the sendcommand. Do you
know
> of
> > > another way to join all connected lines together with only one entity
> > > selected?
> > >
> > >
> > > "Ed Jobe" wrote in message
> > > news:D1FACECEECA8980641C179038F681598@in.WebX.maYIadrTaRb...
> > > > Something else just occured to me. At the point you check for a
pline,
> > you
> > > > only have one ent. You can't make a closed pline with one ent.
You'll
> > have
> > > > to rethink your program logic. Do you offer to make a pline at all,
or
> > > just
> > > > restrict input to plines? If yes to convert to plines, you'll have
to
> > > > reselect to allow multiple ents.
> > > >
> > > > --
> > > > --
> > > > Ed
> > > > --
> > > > "Ed Jobe" wrote in message
> > > > news:4386729F4AA191283425321602C138FA@in.WebX.maYIadrTaRb...
> > > > > I'm leaving pretty quick, so I don't have time to give more
detail,
> > but
> > > > > SendCommand is asyncronous. It is completing after you look for
the
> > last
> > > > > ent. Also, you Dim'ed ss, but didn't create an ss. You might also
> > search
> > > > > this ng on how to make a poly line. That's been discussed before.
> Get
> > > that
> > > > > info and go with Mark's suggestion to create the poly via ActiveX.
> > Then
> > > > you
> > > > > can forget the ss route and SendCommand.
> > > > >
> > > > > --
> > > > > --
> > > > > Ed
> > > > > --
> > > > > "Nathan Guill" wrote in message
> > > > > news:588D9043A9B0E48EB7EB8D4175E4E7CB@in.WebX.maYIadrTaRb...
> > > > > > Basically, I just "joined all" the connected entities to the one
> the
> > > > user
> > > > > > selected to create the pline.
> > > > > >
> > > > > > select doesn't return anything, though.
> > > > > >
> > > > > > Below is the code I have so far. To set it up, just create a
> > > rectangle
> > > > > (not
> > > > > > crossing the X plane) and explode it.
> > > > > >
> > > > > > Function GetWeight()
> > > > > > Dim basePnt As Variant
> > > > > > Dim centerObj As AcadObject
> > > > > > Dim strCenter As String
> > > > > > Dim strWeight As String
> > > > > > Dim Response As VbMsgBoxResult
> > > > > > Dim returnObj As AcadObject
> > > > > > Dim ss As AcadSelectionSet
> > > > > >
> > > > > > ThisDrawing.Utility.InitializeUserInput 1, "Yes No"
> > > > > >
> > > > > > ' Prompt the user to input any of the keywords.
> > > > > > strWeight = ThisDrawing.Utility.GetKeyword("Are you looking
for
> > the
> > > > > weight
> > > > > > (Yes No):")
> > > > > >
> > > > > > ThisDrawing.Utility.InitializeUserInput 8
> > > > > > Start:
> > > > > > ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select
> > > > cross-section
> > > > > > for calculation: "
> > > > > >
> > > > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > > > If Len(returnObj.Handle) = 0 Then
> > > > > > VBA.MsgBox "You must select an entity to continue.",
> > > vbExclamation
> > > > +
> > > > > > vbOKOnly, _
> > > > > > "No Entity"
> > > > > > GoTo Start
> > > > > > End If
> > > > > > Response = VBA.MsgBox("This entity is not a polyline," &
> > > VBA.vbCrLf
> > > > &
> > > > > _
> > > > > > "Should I try and make it one?", vbQuestion + vbYesNo,
> "Wrong
> > > > Entity
> > > > > > Type")
> > > > > >
> > > > > > If Response = vbNo Then End
> > > > > >
> > > > > > ThisDrawing.SendCommand "pedit" & VBA.vbCr &
> > Ent2lspEnt(returnObj)
> > > &
> > > > _
> > > > > > VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr & "All" &
> > > VBA.vbCr
> > > > &
> > > > > > VBA.vbCr & _
> > > > > > VBA.vbCr
> > > > > >
> > > > > > ss.Select acSelectionSetLast
> > > > > > 'returnObj = ThisDrawing.SendCommand("(entlast)")
> > > > > >
> > > > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > > > VBA.MsgBox "This entity cannot be made into a Polyline.",
> > > > > > vbExclamation + vbOKOnly, _
> > > > > > "Wrong Entity Type"
> > > > > > End
> > > > > > End If
> > > > > > End If
> > > > > >
> > > > > > ThisDrawing.Utility.InitializeUserInput 1, "Xaxis Yaxis
Object"
> > > > > >
> > > > > > ' Prompt the user to input any of the keywords.
> > > > > > strCenter = ThisDrawing.Utility.GetKeyword("Select center line
> > > (Xaxis
> > > > > > Yaxis Object):")
> > > > > >
> > > > > > ThisDrawing.Utility.InitializeUserInput 8
> > > > > >
> > > > > > Select Case strCenter
> > > > > > Case "Xaxis"
> > > > > > ThisDrawing.SendCommand "undo mark revolve " & _
> > > > > > FMI_Utilities.FMI.Ent2lspEnt(returnObj) & " X 360 "
> > > > > > Case "Yaxis"
> > > > > > Case "Object"
> > > > > > ThisDrawing.Utility.GetEntity centerObj, basePnt, "Select
> > center
> > > > > line
> > > > > > object: "
> > > > > > Case Else
> > > > > > End
> > > > > > End Select
> > > > > >
> > > > > > ThisDrawing.Utility.GetEntity returnObj, basePnt
> > > > > >
> > > > > > If strWeight = "Yes" Then
> > > > > > VBA.MsgBox "This part weighs " & (returnObj.Volume * 0.297)
&
> "
> > in
> > > > > Inco
> > > > > > 718"
> > > > > > Else
> > > > > > VBA.MsgBox "The volume of this part is " & returnObj.Volume
> > > > > > End If
> > > > > > End Function
> > > > > >
> > > > > > Public Function Ent2lspEnt(entObj As AcadEntity) As String
> > > > > > 'Designed to work with SendCommand, which can't pass objects.
> > > > > > 'This gets an objects handle and converts it to a string
> > > > > > 'of lisp commands that returns an entity name when run in
> > > SendCommand.
> > > > > > Dim entHandle As String
> > > > > > entHandle = entObj.Handle
> > > > > > Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
> > > > > > End Function
> > > > > >
> > > > > > "Ed Jobe" wrote in message
> > > > > > news:1FE06E944FA26D430C181796A59B2F14@in.WebX.maYIadrTaRb...
> > > > > > > If you just created an entity, it will be the last in the db.
> Just
> > > > like
> > > > > > you
> > > > > > > can use the Last argument to any selection prompt in acad, the
> > > > selection
> > > > > > set
> > > > > > > object has this option too.
> > > > > > > Dim ss As AcadSelectionSet
> > > > > > > ss.Select acSelectionSetLast
> > > > > > >
> > > > > > > --
> > > > > > > --
> > > > > > > Ed
> > > > > > > --
> > > > > > > "Nathan Guill" wrote in message
> > > > > > > news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > > > > > > > This is probably staring me in the face, but ...
> > > > > > > >
> > > > > > > > I have a routine that prompts the user for an entity, and if
> > this
> > > > > entity
> > > > > > > is
> > > > > > > > not a closed polyline, then it attempts to make it one for
the
> > > user.
> > > > > > All
> > > > > > > of
> > > > > > > > this works fine, my problem is in the retest. I can't seem
to
> > > > > reselect
> > > > > > > the
> > > > > > > > (now a polyline) entity within the code (i.e. without user
> > > > > interaction).
> > > > > > I
> > > > > > > > obtain the original entity with
ThisDrawing.Utility.GetEntity
> > and
> > > > then
> > > > > > > > create the polyline with sendcommand.
> > > > > > > >
> > > > > > > > Any help would be appreciated.
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 15 of 17

Anonymous
Not applicable
Okay, how do I do that? I know how I can add the entities that share a
starting or ending point with the original entity, but how do I mimic the
"join all" function of PEDIT in ActiveX without creating an infinate loop?
I searched for something already written that might help, but I still don't
understand how to do that.

Am I making sense? Sorry if I'm not.

"Ed Jobe" wrote in message
news:6A3B51A14F1A8A939FD1071E9613423A@in.WebX.maYIadrTaRb...
> That's true. I forgot they added that, it didn't used to do that. I havn't
> used it in a while. But in the context of this discussion, you still had
go
> through the extra step of telling it to add more ents. The command just
> filtered out all the lines that connect to it. You need to duplicate that
> using ActiveX if you aren't going to use SendCommand.
>
> --
> --
> Ed
> --
> "Nathan Guill" wrote in message
> news:BF22288999FE458D9E3773E64A58E215@in.WebX.maYIadrTaRb...
> > I'm sorry to tell you, but if you type PEDIT, select a line, tell it to
> turn
> > it into a pline, then select join and then type in all, any lines
> connected
> > to that first line you selected will then be joined to that line. I
know
> > this works as I do this many times a day. I NEVER have to select more
> than
> > one line as I tell it to join ALL. Since ONLY the entities that share
> some
> > common point can be joined, autocad only joins those entities. Don't
> > beleive me... TRY IT.
> >
> >
> > "Ed Jobe" wrote in message
> > news:2690302D83BEE74598E4956B343E9FEA@in.WebX.maYIadrTaRb...
> > > The PEDIT command joins connected lines, but it doesn't magically find
> > them
> > > for you, you have to select them. If you are going to offer this
feature
> > in
> > > your code, at the point you determine that the single ent they
selected
> is
> > > not a pline (assuming its a line or arc), then you need to prompt the
> user
> > > to select the rest of the ents to perform the join on. Use their
> geometry
> > > info to construct a pline via ActiveX. If you want just get your
command
> > > working for now, only allow them to select plines and quit if they
want
> to
> > > perform the join themselves. You can add the join functionality after
> you
> > > get the bulk of the command working. Check this ng for code on how to
> make
> > a
> > > pline.
> > >
> > > --
> > > --
> > > Ed
> > > --
> > > "Nathan Guill" wrote in message
> > > news:65471D62C2CFC09F5007D338D1F4FAB7@in.WebX.maYIadrTaRb...
> > > > You're right. I only have one entity when I first test for a pline,
> > hence
> > > > the "join all" operation in the sendcommand. Basically, the entity
> the
> > > user
> > > > will be selecting will be part of a cross-section of a ring. If
it's
> a
> > > > closed polyline then it revolves this section and gets a weight,
> > > otherwise,
> > > > it attemps to join all connected lines into a closed polyline then
> gets
> > > the
> > > > weight. That's why I think I have to use the sendcommand. Do you
> know
> > of
> > > > another way to join all connected lines together with only one
entity
> > > > selected?
> > > >
> > > >
> > > > "Ed Jobe" wrote in message
> > > > news:D1FACECEECA8980641C179038F681598@in.WebX.maYIadrTaRb...
> > > > > Something else just occured to me. At the point you check for a
> pline,
> > > you
> > > > > only have one ent. You can't make a closed pline with one ent.
> You'll
> > > have
> > > > > to rethink your program logic. Do you offer to make a pline at
all,
> or
> > > > just
> > > > > restrict input to plines? If yes to convert to plines, you'll have
> to
> > > > > reselect to allow multiple ents.
> > > > >
> > > > > --
> > > > > --
> > > > > Ed
> > > > > --
> > > > > "Ed Jobe" wrote in message
> > > > > news:4386729F4AA191283425321602C138FA@in.WebX.maYIadrTaRb...
> > > > > > I'm leaving pretty quick, so I don't have time to give more
> detail,
> > > but
> > > > > > SendCommand is asyncronous. It is completing after you look for
> the
> > > last
> > > > > > ent. Also, you Dim'ed ss, but didn't create an ss. You might
also
> > > search
> > > > > > this ng on how to make a poly line. That's been discussed
before.
> > Get
> > > > that
> > > > > > info and go with Mark's suggestion to create the poly via
ActiveX.
> > > Then
> > > > > you
> > > > > > can forget the ss route and SendCommand.
> > > > > >
> > > > > > --
> > > > > > --
> > > > > > Ed
> > > > > > --
> > > > > > "Nathan Guill" wrote in message
> > > > > > news:588D9043A9B0E48EB7EB8D4175E4E7CB@in.WebX.maYIadrTaRb...
> > > > > > > Basically, I just "joined all" the connected entities to the
one
> > the
> > > > > user
> > > > > > > selected to create the pline.
> > > > > > >
> > > > > > > select doesn't return anything, though.
> > > > > > >
> > > > > > > Below is the code I have so far. To set it up, just create a
> > > > rectangle
> > > > > > (not
> > > > > > > crossing the X plane) and explode it.
> > > > > > >
> > > > > > > Function GetWeight()
> > > > > > > Dim basePnt As Variant
> > > > > > > Dim centerObj As AcadObject
> > > > > > > Dim strCenter As String
> > > > > > > Dim strWeight As String
> > > > > > > Dim Response As VbMsgBoxResult
> > > > > > > Dim returnObj As AcadObject
> > > > > > > Dim ss As AcadSelectionSet
> > > > > > >
> > > > > > > ThisDrawing.Utility.InitializeUserInput 1, "Yes No"
> > > > > > >
> > > > > > > ' Prompt the user to input any of the keywords.
> > > > > > > strWeight = ThisDrawing.Utility.GetKeyword("Are you looking
> for
> > > the
> > > > > > weight
> > > > > > > (Yes No):")
> > > > > > >
> > > > > > > ThisDrawing.Utility.InitializeUserInput 8
> > > > > > > Start:
> > > > > > > ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select
> > > > > cross-section
> > > > > > > for calculation: "
> > > > > > >
> > > > > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > > > > If Len(returnObj.Handle) = 0 Then
> > > > > > > VBA.MsgBox "You must select an entity to continue.",
> > > > vbExclamation
> > > > > +
> > > > > > > vbOKOnly, _
> > > > > > > "No Entity"
> > > > > > > GoTo Start
> > > > > > > End If
> > > > > > > Response = VBA.MsgBox("This entity is not a polyline," &
> > > > VBA.vbCrLf
> > > > > &
> > > > > > _
> > > > > > > "Should I try and make it one?", vbQuestion + vbYesNo,
> > "Wrong
> > > > > Entity
> > > > > > > Type")
> > > > > > >
> > > > > > > If Response = vbNo Then End
> > > > > > >
> > > > > > > ThisDrawing.SendCommand "pedit" & VBA.vbCr &
> > > Ent2lspEnt(returnObj)
> > > > &
> > > > > _
> > > > > > > VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr & "All"
&
> > > > VBA.vbCr
> > > > > &
> > > > > > > VBA.vbCr & _
> > > > > > > VBA.vbCr
> > > > > > >
> > > > > > > ss.Select acSelectionSetLast
> > > > > > > 'returnObj = ThisDrawing.SendCommand("(entlast)")
> > > > > > >
> > > > > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > > > > VBA.MsgBox "This entity cannot be made into a
Polyline.",
> > > > > > > vbExclamation + vbOKOnly, _
> > > > > > > "Wrong Entity Type"
> > > > > > > End
> > > > > > > End If
> > > > > > > End If
> > > > > > >
> > > > > > > ThisDrawing.Utility.InitializeUserInput 1, "Xaxis Yaxis
> Object"
> > > > > > >
> > > > > > > ' Prompt the user to input any of the keywords.
> > > > > > > strCenter = ThisDrawing.Utility.GetKeyword("Select center
line
> > > > (Xaxis
> > > > > > > Yaxis Object):")
> > > > > > >
> > > > > > > ThisDrawing.Utility.InitializeUserInput 8
> > > > > > >
> > > > > > > Select Case strCenter
> > > > > > > Case "Xaxis"
> > > > > > > ThisDrawing.SendCommand "undo mark revolve " & _
> > > > > > > FMI_Utilities.FMI.Ent2lspEnt(returnObj) & " X 360 "
> > > > > > > Case "Yaxis"
> > > > > > > Case "Object"
> > > > > > > ThisDrawing.Utility.GetEntity centerObj, basePnt,
"Select
> > > center
> > > > > > line
> > > > > > > object: "
> > > > > > > Case Else
> > > > > > > End
> > > > > > > End Select
> > > > > > >
> > > > > > > ThisDrawing.Utility.GetEntity returnObj, basePnt
> > > > > > >
> > > > > > > If strWeight = "Yes" Then
> > > > > > > VBA.MsgBox "This part weighs " & (returnObj.Volume *
0.297)
> &
> > "
> > > in
> > > > > > Inco
> > > > > > > 718"
> > > > > > > Else
> > > > > > > VBA.MsgBox "The volume of this part is " &
returnObj.Volume
> > > > > > > End If
> > > > > > > End Function
> > > > > > >
> > > > > > > Public Function Ent2lspEnt(entObj As AcadEntity) As String
> > > > > > > 'Designed to work with SendCommand, which can't pass
objects.
> > > > > > > 'This gets an objects handle and converts it to a string
> > > > > > > 'of lisp commands that returns an entity name when run in
> > > > SendCommand.
> > > > > > > Dim entHandle As String
> > > > > > > entHandle = entObj.Handle
> > > > > > > Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) &
")"
> > > > > > > End Function
> > > > > > >
> > > > > > > "Ed Jobe" wrote in message
> > > > > > > news:1FE06E944FA26D430C181796A59B2F14@in.WebX.maYIadrTaRb...
> > > > > > > > If you just created an entity, it will be the last in the
db.
> > Just
> > > > > like
> > > > > > > you
> > > > > > > > can use the Last argument to any selection prompt in acad,
the
> > > > > selection
> > > > > > > set
> > > > > > > > object has this option too.
> > > > > > > > Dim ss As AcadSelectionSet
> > > > > > > > ss.Select acSelectionSetLast
> > > > > > > >
> > > > > > > > --
> > > > > > > > --
> > > > > > > > Ed
> > > > > > > > --
> > > > > > > > "Nathan Guill" wrote in message
> > > > > > > > news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > > > > > > > > This is probably staring me in the face, but ...
> > > > > > > > >
> > > > > > > > > I have a routine that prompts the user for an entity, and
if
> > > this
> > > > > > entity
> > > > > > > > is
> > > > > > > > > not a closed polyline, then it attempts to make it one for
> the
> > > > user.
> > > > > > > All
> > > > > > > > of
> > > > > > > > > this works fine, my problem is in the retest. I can't
seem
> to
> > > > > > reselect
> > > > > > > > the
> > > > > > > > > (now a polyline) entity within the code (i.e. without user
> > > > > > interaction).
> > > > > > > I
> > > > > > > > > obtain the original entity with
> ThisDrawing.Utility.GetEntity
> > > and
> > > > > then
> > > > > > > > > create the polyline with sendcommand.
> > > > > > > > >
> > > > > > > > > Any help would be appreciated.
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 16 of 17

Anonymous
Not applicable
I don't have time to do a thorough search for you, but this should get you
started. http://tinyurl.com/ynmh. Take note of the array for the vertices.
It only uses two points. You just have to add more vertices. Use google.com
to seach this ng or use the search feature in the web version. I found this
with just "polyline" as the keyword.

--
--
Ed
--
"Nathan Guill" wrote in message
news:2C0E7310104B18878321281F927837EF@in.WebX.maYIadrTaRb...
> Okay, how do I do that? I know how I can add the entities that share a
> starting or ending point with the original entity, but how do I mimic the
> "join all" function of PEDIT in ActiveX without creating an infinate loop?
> I searched for something already written that might help, but I still
don't
> understand how to do that.
>
> Am I making sense? Sorry if I'm not.
>
> "Ed Jobe" wrote in message
> news:6A3B51A14F1A8A939FD1071E9613423A@in.WebX.maYIadrTaRb...
> > That's true. I forgot they added that, it didn't used to do that. I
havn't
> > used it in a while. But in the context of this discussion, you still had
> go
> > through the extra step of telling it to add more ents. The command just
> > filtered out all the lines that connect to it. You need to duplicate
that
> > using ActiveX if you aren't going to use SendCommand.
> >
> > --
> > --
> > Ed
> > --
> > "Nathan Guill" wrote in message
> > news:BF22288999FE458D9E3773E64A58E215@in.WebX.maYIadrTaRb...
> > > I'm sorry to tell you, but if you type PEDIT, select a line, tell it
to
> > turn
> > > it into a pline, then select join and then type in all, any lines
> > connected
> > > to that first line you selected will then be joined to that line. I
> know
> > > this works as I do this many times a day. I NEVER have to select more
> > than
> > > one line as I tell it to join ALL. Since ONLY the entities that share
> > some
> > > common point can be joined, autocad only joins those entities. Don't
> > > beleive me... TRY IT.
> > >
> > >
> > > "Ed Jobe" wrote in message
> > > news:2690302D83BEE74598E4956B343E9FEA@in.WebX.maYIadrTaRb...
> > > > The PEDIT command joins connected lines, but it doesn't magically
find
> > > them
> > > > for you, you have to select them. If you are going to offer this
> feature
> > > in
> > > > your code, at the point you determine that the single ent they
> selected
> > is
> > > > not a pline (assuming its a line or arc), then you need to prompt
the
> > user
> > > > to select the rest of the ents to perform the join on. Use their
> > geometry
> > > > info to construct a pline via ActiveX. If you want just get your
> command
> > > > working for now, only allow them to select plines and quit if they
> want
> > to
> > > > perform the join themselves. You can add the join functionality
after
> > you
> > > > get the bulk of the command working. Check this ng for code on how
to
> > make
> > > a
> > > > pline.
> > > >
> > > > --
> > > > --
> > > > Ed
> > > > --
> > > > "Nathan Guill" wrote in message
> > > > news:65471D62C2CFC09F5007D338D1F4FAB7@in.WebX.maYIadrTaRb...
> > > > > You're right. I only have one entity when I first test for a
pline,
> > > hence
> > > > > the "join all" operation in the sendcommand. Basically, the
entity
> > the
> > > > user
> > > > > will be selecting will be part of a cross-section of a ring. If
> it's
> > a
> > > > > closed polyline then it revolves this section and gets a weight,
> > > > otherwise,
> > > > > it attemps to join all connected lines into a closed polyline then
> > gets
> > > > the
> > > > > weight. That's why I think I have to use the sendcommand. Do you
> > know
> > > of
> > > > > another way to join all connected lines together with only one
> entity
> > > > > selected?
> > > > >
> > > > >
> > > > > "Ed Jobe" wrote in message
> > > > > news:D1FACECEECA8980641C179038F681598@in.WebX.maYIadrTaRb...
> > > > > > Something else just occured to me. At the point you check for a
> > pline,
> > > > you
> > > > > > only have one ent. You can't make a closed pline with one ent.
> > You'll
> > > > have
> > > > > > to rethink your program logic. Do you offer to make a pline at
> all,
> > or
> > > > > just
> > > > > > restrict input to plines? If yes to convert to plines, you'll
have
> > to
> > > > > > reselect to allow multiple ents.
> > > > > >
> > > > > > --
> > > > > > --
> > > > > > Ed
> > > > > > --
> > > > > > "Ed Jobe" wrote in message
> > > > > > news:4386729F4AA191283425321602C138FA@in.WebX.maYIadrTaRb...
> > > > > > > I'm leaving pretty quick, so I don't have time to give more
> > detail,
> > > > but
> > > > > > > SendCommand is asyncronous. It is completing after you look
for
> > the
> > > > last
> > > > > > > ent. Also, you Dim'ed ss, but didn't create an ss. You might
> also
> > > > search
> > > > > > > this ng on how to make a poly line. That's been discussed
> before.
> > > Get
> > > > > that
> > > > > > > info and go with Mark's suggestion to create the poly via
> ActiveX.
> > > > Then
> > > > > > you
> > > > > > > can forget the ss route and SendCommand.
> > > > > > >
> > > > > > > --
> > > > > > > --
> > > > > > > Ed
> > > > > > > --
> > > > > > > "Nathan Guill" wrote in message
> > > > > > > news:588D9043A9B0E48EB7EB8D4175E4E7CB@in.WebX.maYIadrTaRb...
> > > > > > > > Basically, I just "joined all" the connected entities to the
> one
> > > the
> > > > > > user
> > > > > > > > selected to create the pline.
> > > > > > > >
> > > > > > > > select doesn't return anything, though.
> > > > > > > >
> > > > > > > > Below is the code I have so far. To set it up, just create
a
> > > > > rectangle
> > > > > > > (not
> > > > > > > > crossing the X plane) and explode it.
> > > > > > > >
> > > > > > > > Function GetWeight()
> > > > > > > > Dim basePnt As Variant
> > > > > > > > Dim centerObj As AcadObject
> > > > > > > > Dim strCenter As String
> > > > > > > > Dim strWeight As String
> > > > > > > > Dim Response As VbMsgBoxResult
> > > > > > > > Dim returnObj As AcadObject
> > > > > > > > Dim ss As AcadSelectionSet
> > > > > > > >
> > > > > > > > ThisDrawing.Utility.InitializeUserInput 1, "Yes No"
> > > > > > > >
> > > > > > > > ' Prompt the user to input any of the keywords.
> > > > > > > > strWeight = ThisDrawing.Utility.GetKeyword("Are you
looking
> > for
> > > > the
> > > > > > > weight
> > > > > > > > (Yes No):")
> > > > > > > >
> > > > > > > > ThisDrawing.Utility.InitializeUserInput 8
> > > > > > > > Start:
> > > > > > > > ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select
> > > > > > cross-section
> > > > > > > > for calculation: "
> > > > > > > >
> > > > > > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > > > > > If Len(returnObj.Handle) = 0 Then
> > > > > > > > VBA.MsgBox "You must select an entity to continue.",
> > > > > vbExclamation
> > > > > > +
> > > > > > > > vbOKOnly, _
> > > > > > > > "No Entity"
> > > > > > > > GoTo Start
> > > > > > > > End If
> > > > > > > > Response = VBA.MsgBox("This entity is not a polyline," &
> > > > > VBA.vbCrLf
> > > > > > &
> > > > > > > _
> > > > > > > > "Should I try and make it one?", vbQuestion + vbYesNo,
> > > "Wrong
> > > > > > Entity
> > > > > > > > Type")
> > > > > > > >
> > > > > > > > If Response = vbNo Then End
> > > > > > > >
> > > > > > > > ThisDrawing.SendCommand "pedit" & VBA.vbCr &
> > > > Ent2lspEnt(returnObj)
> > > > > &
> > > > > > _
> > > > > > > > VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr &
"All"
> &
> > > > > VBA.vbCr
> > > > > > &
> > > > > > > > VBA.vbCr & _
> > > > > > > > VBA.vbCr
> > > > > > > >
> > > > > > > > ss.Select acSelectionSetLast
> > > > > > > > 'returnObj = ThisDrawing.SendCommand("(entlast)")
> > > > > > > >
> > > > > > > > If Not TypeOf returnObj Is AcadLWPolyline Then
> > > > > > > > VBA.MsgBox "This entity cannot be made into a
> Polyline.",
> > > > > > > > vbExclamation + vbOKOnly, _
> > > > > > > > "Wrong Entity Type"
> > > > > > > > End
> > > > > > > > End If
> > > > > > > > End If
> > > > > > > >
> > > > > > > > ThisDrawing.Utility.InitializeUserInput 1, "Xaxis Yaxis
> > Object"
> > > > > > > >
> > > > > > > > ' Prompt the user to input any of the keywords.
> > > > > > > > strCenter = ThisDrawing.Utility.GetKeyword("Select center
> line
> > > > > (Xaxis
> > > > > > > > Yaxis Object):")
> > > > > > > >
> > > > > > > > ThisDrawing.Utility.InitializeUserInput 8
> > > > > > > >
> > > > > > > > Select Case strCenter
> > > > > > > > Case "Xaxis"
> > > > > > > > ThisDrawing.SendCommand "undo mark revolve " & _
> > > > > > > > FMI_Utilities.FMI.Ent2lspEnt(returnObj) & " X 360 "
> > > > > > > > Case "Yaxis"
> > > > > > > > Case "Object"
> > > > > > > > ThisDrawing.Utility.GetEntity centerObj, basePnt,
> "Select
> > > > center
> > > > > > > line
> > > > > > > > object: "
> > > > > > > > Case Else
> > > > > > > > End
> > > > > > > > End Select
> > > > > > > >
> > > > > > > > ThisDrawing.Utility.GetEntity returnObj, basePnt
> > > > > > > >
> > > > > > > > If strWeight = "Yes" Then
> > > > > > > > VBA.MsgBox "This part weighs " & (returnObj.Volume *
> 0.297)
> > &
> > > "
> > > > in
> > > > > > > Inco
> > > > > > > > 718"
> > > > > > > > Else
> > > > > > > > VBA.MsgBox "The volume of this part is " &
> returnObj.Volume
> > > > > > > > End If
> > > > > > > > End Function
> > > > > > > >
> > > > > > > > Public Function Ent2lspEnt(entObj As AcadEntity) As String
> > > > > > > > 'Designed to work with SendCommand, which can't pass
> objects.
> > > > > > > > 'This gets an objects handle and converts it to a string
> > > > > > > > 'of lisp commands that returns an entity name when run in
> > > > > SendCommand.
> > > > > > > > Dim entHandle As String
> > > > > > > > entHandle = entObj.Handle
> > > > > > > > Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) &
> ")"
> > > > > > > > End Function
> > > > > > > >
> > > > > > > > "Ed Jobe" wrote in message
> > > > > > > > news:1FE06E944FA26D430C181796A59B2F14@in.WebX.maYIadrTaRb...
> > > > > > > > > If you just created an entity, it will be the last in the
> db.
> > > Just
> > > > > > like
> > > > > > > > you
> > > > > > > > > can use the Last argument to any selection prompt in acad,
> the
> > > > > > selection
> > > > > > > > set
> > > > > > > > > object has this option too.
> > > > > > > > > Dim ss As AcadSelectionSet
> > > > > > > > > ss.Select acSelectionSetLast
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > --
> > > > > > > > > Ed
> > > > > > > > > --
> > > > > > > > > "Nathan Guill" wrote in message
> > > > > > > > >
news:D5E4A8C60E0074F0EC38BF7722C37DC0@in.WebX.maYIadrTaRb...
> > > > > > > > > > This is probably staring me in the face, but ...
> > > > > > > > > >
> > > > > > > > > > I have a routine that prompts the user for an entity,
and
> if
> > > > this
> > > > > > > entity
> > > > > > > > > is
> > > > > > > > > > not a closed polyline, then it attempts to make it one
for
> > the
> > > > > user.
> > > > > > > > All
> > > > > > > > > of
> > > > > > > > > > this works fine, my problem is in the retest. I can't
> seem
> > to
> > > > > > > reselect
> > > > > > > > > the
> > > > > > > > > > (now a polyline) entity within the code (i.e. without
user
> > > > > > > interaction).
> > > > > > > > I
> > > > > > > > > > obtain the original entity with
> > ThisDrawing.Utility.GetEntity
> > > > and
> > > > > > then
> > > > > > > > > > create the polyline with sendcommand.
> > > > > > > > > >
> > > > > > > > > > Any help would be appreciated.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
0 Likes
Message 17 of 17

Anonymous
Not applicable
Nathan,
If you put a generous pause after the sendcommand, does it give ACAD time
to create the pline? It's clunky, but if you've already got code done and
you're going to be the main one using it, and it doesn't have to be
bulletproof....

James


ThisDrawing.SendCommand "pedit" & VBA.vbCr & Ent2lspEnt(returnObj) & _
VBA.vbCr & "Yes" & VBA.vbCr & "Join" & VBA.vbCr & "All" & VBA.vbCr &
VBA.vbCr & _
VBA.vbCr

'don't run this within 5 seconds of midnite, or you're in trouble....
Dim endt As Double, wait As Double
wait = 5 'seconds
endt = Timer + wait
Do Until Timer > endt: DoEvents: Loop

ss.Select acSelectionSetLast
'returnObj = ThisDrawing.SendCommand("(entlast)")
0 Likes