Create region from closed polyline

Create region from closed polyline

Anonymous
Not applicable
584 Views
2 Replies
Message 1 of 3

Create region from closed polyline

Anonymous
Not applicable
Hello, I am trying to create a region from a closed polyline that is previosly created. Does anyone have sample code that I can use. I appreciate any help.

Here is what I think should of worked:

Public Function AddExtruedSolidAlongPath(objEnt, objDrawingObject)
Dim objExtrusion As Acad3DSolid
Dim varRegion As Variant

With ThisDrawing.ModelSpace
varRegion = .AddRegion(objDrawingObject)
Set objExtrusion = .AddExtrudedSolidAlongPath(varRegion, objEnt)
End With

End Function

Thanks,
Jason Barnett
0 Likes
585 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Jason,

This example from my book should help you out.

Private Sub cmdDrawExtrudedSolidAlongPath_Click()
Dim objCurves(0 To 1) As Object
Dim objAcadSolid As Acad3DSolid
Dim varAcadRegion As Variant
Dim dblCenterPoint(0 To 2) As Double
Dim dblRadius As Double
Dim dblStartAngle As Double
Dim dblEndAngle As Double
Dim objAcadSpline As AcadSpline
Dim varStartTangent As Variant
Dim varEndTangent As Variant
Dim intNumberOfPoints As Integer
Dim varFitPoints As Variant
'CreateTypedArray needs to be late bound
Dim objUtility As Object

'define the number of contour lines
ThisDrawing.Database.Preferences.ContourLinesPerSurface = 10

'define the arc parameters
dblCenterPoint(0) = 5#: dblCenterPoint(1) = 3#: dblCenterPoint(2) = 0#
dblRadius = 2#
dblStartAngle = 0
dblEndAngle = DegreesToRadians(180)

'create an arc
Set objCurves(0) = ThisDrawing.ModelSpace.AddArc(dblCenterPoint,
dblRadius, dblStartAngle, dblEndAngle)

'create a line
Set objCurves(1) = ThisDrawing.ModelSpace.AddLine(objCurves(0).StartPoint,
objCurves(0).EndPoint)

'create a region based on the above arc and line
varAcadRegion = ThisDrawing.ModelSpace.AddRegion(objCurves)
varAcadRegion(0).Color = acCyan

Set objUtility = ThisDrawing.Utility

'define a spline for the extrusion path
objUtility.CreateTypedArray varStartTangent, vbDouble, 10, 10, 10
objUtility.CreateTypedArray varEndTangent, vbDouble, 10, 10, 10

objUtility.CreateTypedArray varFitPoints, vbDouble, 0, 10, 10, 10, 10, 10,
15, 10, 10
intNumberOfPoints = 3
Set objAcadSpline = ThisDrawing.ModelSpace.AddSpline(varFitPoints,
varStartTangent, varEndTangent)

'create the solid
Set objAcadSolid =
ThisDrawing.ModelSpace.AddExtrudedSolidAlongPath(varAcadRegion(0),
objAcadSpline)
objAcadSolid.Color = acRed
ThisDrawing.Application.ZoomAll
End Sub
--
Joe Sutphin
Author of "AutoCAD 2000 VBA Programmers Reference"
ISBN #1861002564

Checkout Sources - The magazine dedicated to AutoCAD customization
http://vbdesign.hypermart.net/sources/sources.htm

Visit our website http://vbdesign.hypermart.net/sources/sources.htm and find
out how you can reserve your
copy of the book "The Complete AutoCAD R14.01 and 2000 VBA Reference Guide"

jbarnett wrote in message
news:ef29b6c.-1@WebX.SaUCah8kaAW...
> Hello, I am trying to create a region from a closed polyline that is
previosly created. Does anyone have sample code that I can use. I
appreciate any help.
>
> Here is what I think should of worked:
>
> Public Function AddExtruedSolidAlongPath(objEnt, objDrawingObject)
> Dim objExtrusion As Acad3DSolid
> Dim varRegion As Variant
>
> With ThisDrawing.ModelSpace
> varRegion = .AddRegion(objDrawingObject)
> Set objExtrusion = .AddExtrudedSolidAlongPath(varRegion, objEnt)
> End With
>
> End Function
>
> Thanks,
> Jason Barnett
0 Likes
Message 3 of 3

Anonymous
Not applicable
Once the region has been created, varRegion becomes an array of AcadRegions,
not a reference to the regions themselves. If you want to access a
particular region do something like this: varRegion(Index)

--
Attitudes are contagious. Is yours worth catching?
http://www.acadx.com

"jbarnett" wrote in message
news:ef29b6c.-1@WebX.SaUCah8kaAW...
> Hello, I am trying to create a region from a closed polyline that is
previosly created. Does anyone have sample code that I can use. I
appreciate any help.
>
> Here is what I think should of worked:
>
> Public Function AddExtruedSolidAlongPath(objEnt, objDrawingObject)
> Dim objExtrusion As Acad3DSolid
> Dim varRegion As Variant
>
> With ThisDrawing.ModelSpace
> varRegion = .AddRegion(objDrawingObject)
> Set objExtrusion = .AddExtrudedSolidAlongPath(varRegion, objEnt)
> End With
>
> End Function
>
> Thanks,
> Jason Barnett
0 Likes