Ak2 VBA help for Extrusion

Ak2 VBA help for Extrusion

Anonymous
Not applicable
243 Views
6 Replies
Message 1 of 7

Ak2 VBA help for Extrusion

Anonymous
Not applicable
Hi:

Can some one look in to following code and tell me why am I getting error?
All am trying to do is add a polyline, select the last added item in
selection set, make a region out of selection set (This is where I get
error) and finally extrude the region.

The objective is to extrude LWPolyline. If you have any other suggestions
to accomplish the same, please let me know. Thanks in advance.

Sub aaaa()
Dim plineObj As AcadPolyline
Dim points(0 To 14) As Double
Dim ssetObj As AcadSelectionSet
Dim ssetcoll As AcadSelectionSets
Dim region_a(0 To 1) As AcadRegion
Dim solid1 As Acad3DSolid

points(0) = 0: points(1) = 0: points(2) = 0
points(3) = 0: points(4) = 1: points(5) = 0
points(6) = 1: points(7) = 1: points(8) = 0
points(9) = 1: points(10) = 0: points(11) = 0
points(12) = 0: points(13) = 0: points(14) = 0
Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
Set ssetcoll = ThisDrawing.SelectionSets
Name1 = "m1"
' this will have to change everytime you rerun during debugging
Set ssetObj = ssetcoll.Add(Name1)
ssetObj.Select acSelectionSetLast
region_a(0) = ssetObj.Item("0")
Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a(0), 100,
0)
ssetObj.Delete
End Sub
0 Likes
244 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
In this case, there is no need for a selection set. You already have the object
you want to extrude, just pass it to the array. Also, you pass the entire array,
not just a single element of it, to the AddExtrudeSolid method:

Set region_a(0) = plineObj
Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a, 100, 0)

HTH

--
http://www.acadx.com
"Thank goodness! I thought my boots were cracked."

"Vpatel" wrote in message
news:BF95CCBB29A648730F5B0ADF06ADE313@in.WebX.maYIadrTaRb...
> Hi:
>
> Can some one look in to following code and tell me why am I getting error?
> All am trying to do is add a polyline, select the last added item in
> selection set, make a region out of selection set (This is where I get
> error) and finally extrude the region.
>
> The objective is to extrude LWPolyline. If you have any other suggestions
> to accomplish the same, please let me know. Thanks in advance.
0 Likes
Message 3 of 7

Anonymous
Not applicable
If I try your suggested solution, I get error (type mismatch). Following is
the code after taking your comments in to account. Please look and see if
you can help. Thanks.
Viral

Sub add_ucs2()
Dim plineObj As AcadPolyline
Dim points(0 To 14) As Double
points(0) = 0: points(1) = 0: points(2) = 0
points(3) = 0: points(4) = 1: points(5) = 0
points(6) = 1: points(7) = 1: points(8) = 0
points(9) = 1: points(10) = 0: points(11) = 0
points(12) = 0: points(13) = 0: points(14) = 0
Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
Dim region_a As AcadRegion
Set region_a = plineObj
Dim solid1 As Acad3DSolid
Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a, 100, 0)
ssetObj.Delete

End Sub

"Frank Oquendo" wrote in message
news:CDFFF991D1662297FA07812B29641D62@in.WebX.maYIadrTaRb...
> In this case, there is no need for a selection set. You already have the
object
> you want to extrude, just pass it to the array. Also, you pass the entire
array,
> not just a single element of it, to the AddExtrudeSolid method:
>
> Set region_a(0) = plineObj
> Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a, 100, 0)
>
> HTH
>
> --
> http://www.acadx.com
> "Thank goodness! I thought my boots were cracked."
>
> "Vpatel" wrote in message
> news:BF95CCBB29A648730F5B0ADF06ADE313@in.WebX.maYIadrTaRb...
> > Hi:
> >
> > Can some one look in to following code and tell me why am I getting
error?
> > All am trying to do is add a polyline, select the last added item in
> > selection set, make a region out of selection set (This is where I get
> > error) and finally extrude the region.
> >
> > The objective is to extrude LWPolyline. If you have any other
suggestions
> > to accomplish the same, please let me know. Thanks in advance.
>
>
0 Likes
Message 4 of 7

Anonymous
Not applicable
Region_A is supposed to be an array of AcadEntity or any descendant
thereof:

Dim region_a(0) As AcadEntity
Set region_a(0) = plineObj

--
http://www.acadx.com
"Thank goodness! I thought my boots were cracked."
"V Patel" wrote in message
news:6FA928DFB9741D7FEBF4369A18DC1344@in.WebX.maYIadrTaRb...
> If I try your suggested solution, I get error (type mismatch).
Following is
> the code after taking your comments in to account. Please look and
see if
> you can help. Thanks.
> Viral
>
> Sub add_ucs2()
> Dim plineObj As AcadPolyline
> Dim points(0 To 14) As Double
> points(0) = 0: points(1) = 0: points(2) = 0
> points(3) = 0: points(4) = 1: points(5) = 0
> points(6) = 1: points(7) = 1: points(8) = 0
> points(9) = 1: points(10) = 0: points(11) = 0
> points(12) = 0: points(13) = 0: points(14) = 0
> Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
> Dim region_a As AcadRegion
> Set region_a = plineObj
> Dim solid1 As Acad3DSolid
> Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a,
100, 0)
> ssetObj.Delete
>
> End Sub
>
> "Frank Oquendo" wrote in message
> news:CDFFF991D1662297FA07812B29641D62@in.WebX.maYIadrTaRb...
> > In this case, there is no need for a selection set. You already
have the
> object
> > you want to extrude, just pass it to the array. Also, you pass the
entire
> array,
> > not just a single element of it, to the AddExtrudeSolid method:
> >
> > Set region_a(0) = plineObj
> > Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a,
100, 0)
> >
> > HTH
> >
> > --
> > http://www.acadx.com
> > "Thank goodness! I thought my boots were cracked."
> >
> > "Vpatel" wrote in message
> > news:BF95CCBB29A648730F5B0ADF06ADE313@in.WebX.maYIadrTaRb...
> > > Hi:
> > >
> > > Can some one look in to following code and tell me why am I
getting
> error?
> > > All am trying to do is add a polyline, select the last added
item in
> > > selection set, make a region out of selection set (This is where
I get
> > > error) and finally extrude the region.
> > >
> > > The objective is to extrude LWPolyline. If you have any other
> suggestions
> > > to accomplish the same, please let me know. Thanks in advance.
> >
> >
>
0 Likes
Message 5 of 7

Anonymous
Not applicable
If region_a(0) is defined as AcadEntity, the Set region_a(0) = plineObj
works fine but in the following statement "Type mismatch" error is produced.
It appears that the AddExctrudSolid needs Region not AcadEntity.

Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a(0),100, 0)

Thanks or help.
V Patel

"Frank Oquendo" wrote in message
news:441E63FAC5E3DD7E60A102D65C89E53B@in.WebX.maYIadrTaRb...
> Region_A is supposed to be an array of AcadEntity or any descendant
> thereof:
>
> Dim region_a(0) As AcadEntity
> Set region_a(0) = plineObj
>
> --
> http://www.acadx.com
> "Thank goodness! I thought my boots were cracked."
> "V Patel" wrote in message
> news:6FA928DFB9741D7FEBF4369A18DC1344@in.WebX.maYIadrTaRb...
> > If I try your suggested solution, I get error (type mismatch).
> Following is
> > the code after taking your comments in to account. Please look and
> see if
> > you can help. Thanks.
> > Viral
> >
> > Sub add_ucs2()
> > Dim plineObj As AcadPolyline
> > Dim points(0 To 14) As Double
> > points(0) = 0: points(1) = 0: points(2) = 0
> > points(3) = 0: points(4) = 1: points(5) = 0
> > points(6) = 1: points(7) = 1: points(8) = 0
> > points(9) = 1: points(10) = 0: points(11) = 0
> > points(12) = 0: points(13) = 0: points(14) = 0
> > Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
> > Dim region_a As AcadRegion
> > Set region_a = plineObj
> > Dim solid1 As Acad3DSolid
> > Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a,
> 100, 0)
> > ssetObj.Delete
> >
> > End Sub
> >
> > "Frank Oquendo" wrote in message
> > news:CDFFF991D1662297FA07812B29641D62@in.WebX.maYIadrTaRb...
> > > In this case, there is no need for a selection set. You already
> have the
> > object
> > > you want to extrude, just pass it to the array. Also, you pass the
> entire
> > array,
> > > not just a single element of it, to the AddExtrudeSolid method:
> > >
> > > Set region_a(0) = plineObj
> > > Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a,
> 100, 0)
> > >
> > > HTH
> > >
> > > --
> > > http://www.acadx.com
> > > "Thank goodness! I thought my boots were cracked."
> > >
> > > "Vpatel" wrote in message
> > > news:BF95CCBB29A648730F5B0ADF06ADE313@in.WebX.maYIadrTaRb...
> > > > Hi:
> > > >
> > > > Can some one look in to following code and tell me why am I
> getting
> > error?
> > > > All am trying to do is add a polyline, select the last added
> item in
> > > > selection set, make a region out of selection set (This is where
> I get
> > > > error) and finally extrude the region.
> > > >
> > > > The objective is to extrude LWPolyline. If you have any other
> > suggestions
> > > > to accomplish the same, please let me know. Thanks in advance.
> > >
> > >
> >
>
0 Likes
Message 6 of 7

Anonymous
Not applicable
In that case, have you made a region from your polyline?

--
http://www.acadx.com
"Thank goodness! I thought my boots were cracked."

"V Patel" wrote in message
news:53AA0B04B486EAF913108E95675ACD63@in.WebX.maYIadrTaRb...
> If region_a(0) is defined as AcadEntity, the Set region_a(0) = plineObj
> works fine but in the following statement "Type mismatch" error is produced.
> It appears that the AddExctrudSolid needs Region not AcadEntity.
>
> Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a(0),100, 0)
>
> Thanks or help.
> V Patel
0 Likes
Message 7 of 7

Anonymous
Not applicable
No from the dim statement, I just made AcadEntity and not AcadRegion. That
is the reason why "Type mismatch" error is produced.

The question is how one can make region from the polyline that was just
drawn.

Thanks again for help.

"Frank Oquendo" wrote in message
news:BD841B654AEF483EACEFB976CC4D5848@in.WebX.maYIadrTaRb...
> In that case, have you made a region from your polyline?
>
> --
> http://www.acadx.com
> "Thank goodness! I thought my boots were cracked."
>
> "V Patel" wrote in message
> news:53AA0B04B486EAF913108E95675ACD63@in.WebX.maYIadrTaRb...
> > If region_a(0) is defined as AcadEntity, the Set region_a(0) = plineObj
> > works fine but in the following statement "Type mismatch" error is
produced.
> > It appears that the AddExctrudSolid needs Region not AcadEntity.
> >
> > Set solid1 = ThisDrawing.ModelSpace.AddExtrudedSolid(region_a(0),100, 0)
> >
> > Thanks or help.
> > V Patel
>
0 Likes