sendcommand alternative ???

sendcommand alternative ???

Anonymous
Not applicable
508 Views
4 Replies
Message 1 of 5

sendcommand alternative ???

Anonymous
Not applicable
Hello all,



I'm slowly but surly
learning about programming with AutoCAD. I have a macro that has about
10 commands that operate in sequence. I've tried to experiment with the
sendcommand but I have learned that the commands don't work in
sequence. Is there an easy way around this?



The first part of what I want to accomplish is:



1. freeze the "engraving" layer so it does not explode.

2. Explode everything else (down to the smallest components)

3. unfreeze the "engraving layer".



Here is a partial of what I have.



Private Sub CommandButton1_Click()

ThisDrawing.Layer s.Item("Engraving"). Freeze = True

ThisDrawing.SendCommand "XPLODE" & vbCr & "ALL" & vbCr & "" & vbCr & "G" & vbCr '& vbCr

ThisDrawing.Layers.Item("Engraving").Freeze = False



End Sub



I am starting with this portion hoping that I will be able to apply what I learn to the rest of my code.



Edited by: SHAWN.FERNANDEZ@OTIS.COM on Nov 14, 2008 1:27 PM Edited by: SHAWN.FERNANDEZ@OTIS.COM on Nov 14, 2008 1:27 PM
0 Likes
509 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
I found that if you use the sendcommand in a function you can get it to work sequentially

Private Sub CommandButton1_Click()

ThisDrawing.Layer s.Item("Engraving"). Freeze = True

explodecommand

ThisDrawing.Layers.Item("Engraving").Freeze = False

End Sub

Public Function explodecommand()
ThisDrawing.SendCommand "XPLODE" & vbCr & "ALL" & vbCr & "" & vbCr & "G" & vbCr '& vbCr
End Function


Hope this helps
0 Likes
Message 3 of 5

Anonymous
Not applicable

For starter programmer, especially if you have some
LISP background, one of the most important things to remember is to NOT use
sendcommand() at all, unless that is the only option, assuming you do know VBA
way of doing things. To do things in the way VBA does, in your case, you use
AcadLayer.Freeze propertity (you already used) and AcadBlockReference.Explode()
method. If your VBA program is a bit more complicated than the code you showed,
Sedcommand() with your VBA code will most likely give you unexpected result, or
simply not work.

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hello
all,



I'm slowly but surly
learning about programming with
AutoCAD. I have a macro that has about
10 commands that operate in
sequence. I've tried to experiment with the
sendcommand but I have learned
that the commands don't work in
sequence. Is there an easy way around this?




The first part of what I want to accomplish
is:



1. freeze the "engraving" layer so it does not explode.


2. Explode everything else (down to the smallest components)

3.
unfreeze the "engraving layer".



Here is a partial of what I
have.



Private Sub
CommandButton1_Click()

ThisDrawing.Layer s.Item("Engraving"). Freeze =
True

ThisDrawing.SendCommand "XPLODE" & vbCr & "ALL" & vbCr
& "" & vbCr & "G" & vbCr '&
vbCr

ThisDrawing.Layers.Item("Engraving").Freeze =
False



End Sub



I am starting with this portion
hoping that I will be able to apply what I learn to the rest of my
code.



Edited by: SHAWN.FERNANDEZ@OTIS.COM on Nov 14, 2008 1:27
PM Edited by: SHAWN.FERNANDEZ@OTIS.COM on Nov 14, 2008 1:27
PM
0 Likes
Message 4 of 5

Anonymous
Not applicable
You guys were a big help. I was able to accomplish my mission.

Thanks again !!
0 Likes
Message 5 of 5

Anonymous
Not applicable
Hi SHAWN,

The easiest way by a long way is to abandon the "Sendcommand" process
entirely and use VBA techniques.

Start by making a Selectionset of all explodable objects:

3DPolyline , BlockRef, ExternalReference, LightweightPolyline,
MInsertBlock, Polygonmesh, Polyline, Region

Then loop through the Selectionset and explode each one individually.

When you explode an object you are left with a set of new objects which
you can check for explodability and explode as needed.

There is no need to freeze and thaw layers.

To get yourself started look in the help for "explode" and at the sample
code.

Also search for Selectionset



Regards


Laurie Comerford

SHAWN.FERNANDEZ@OTIS.COM wrote:
> Hello all,
>
>
>
> I'm slowly but surly
> learning about programming with AutoCAD. I have a macro that has about
> 10 commands that operate in sequence. I've tried to experiment with the
> sendcommand but I have learned that the commands don't work in
> sequence. Is there an easy way around this?
>
>
>
> The first part of what I want to accomplish is:
>
>
>
> 1. freeze the "engraving" layer so it does not explode.
>
> 2. Explode everything else (down to the smallest components)
>
> 3. unfreeze the "engraving layer".
>
>
>
> Here is a partial of what I have.
>
>
>
> Private Sub CommandButton1_Click()
>
> ThisDrawing.Layer s.Item("Engraving"). Freeze = True
>
> ThisDrawing.SendCommand "XPLODE" & vbCr & "ALL" & vbCr & "" & vbCr & "G"
> & vbCr '& vbCr
>
> ThisDrawing.Layers.Item("Engraving").Freeze = False
>
>
>
> End Sub
>
>
>
> I am starting with this portion hoping that I will be able to apply what
> I learn to the rest of my code.
>
>
>
> Edited by: SHAWN.FERNANDEZ@OTIS.COM on Nov 14, 2008 1:27 PM Edited by:
> SHAWN.FERNANDEZ@OTIS.COM on Nov 14, 2008 1:27 PM
0 Likes