Polyline to Region conversion?

Discussion in 'AutoCAD' started by David Hartley, Feb 18, 2004.

  1. This is probably a trivial thing to most of you, but I'm new at VBA. I
    can't seem to find a statement that converts a closed polyline into an
    AcadRegion for extruding.

    Dim varRegions As Variant
    Dim shape As AcadLWPolyline

    With ThisDrawing.ModelSpace
    varRegions = .AddRegion(shape)
    End With

    Any help would be appreciated

    David
     
    David Hartley, Feb 18, 2004
    #1
  2. David Hartley

    Mark Propst Guest

    well, I don't think you have to convert a pline to a region in order to
    extrude it, but...
    if you can translate lisp, here's a little snip from a routine that does
    create a region from a pline
    (assuming you need a region for other reasons)

    ;get the pline object reference
    (setq opline(GetObject lwp))

    ;create an array containing the pline object
    (setq array(list->variant vlax-vbObject (list opline)))

    ;pass the array to add region method
    (setq oRegion(car(variantval (vlax-invoke-method *mspace* 'AddRegion
    array))))


    hth
    Mark
     
    Mark Propst, Feb 19, 2004
    #2
  3. David Hartley

    wivory Guest

    As Mark implied, you may just be able to set the Thickness property of your polyline to achieve your extrusion.

    Regards

    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    wivory, Feb 19, 2004
    #3
  4. David Hartley

    SpeedCAD Guest

    Hi...

    I pass an example to you:

    Private Sub Pol2Reg()
    Dim Region As Variant
    Dim Objeto(0) As AcadEntity
    Dim selEntidad As AcadEntity
    Dim Solido As Acad3DSolid
    Dim Punto As Variant
    Dim Altura As Double
    Dim Angulo As Double
    Altura = 10
    Angulo = 0
    autocadApp.ActiveDocument.Utility.GetEntity Objeto(0), Punto, vbCr & "Seleccione objeto: "
    If TypeOf Objeto(0) Is AcadLWPolyline Or _
    TypeOf Objeto(0) Is AcadPolyline Then
    If Objeto(0).Closed = True Then
    Region = autocadApp.ActiveDocument.ModelSpace.AddRegion(Objeto)
    Objeto(0).Delete
    Set Solido = autocadApp.ActiveDocument.ModelSpace.AddExtrudedSolid(Region(0), Altura, Angulo)
    Solido.Color = acBlue
    Else
    MsgBox "La Polilínea debe estar cerrada."
    End If
    Else
    MsgBox "El objeto debe ser una Polilínea."
    End If
    End Sub

    If they are more objects you must increase the size of the array of the variable Objecto. For example Dim Objeto(0 to 1) As AcadEntity, this for two Polylines.

    Un saludo de SpeedCAD... :)
    CHILE
    FORO: http://www.hispacad.com/foro
     
    SpeedCAD, Feb 19, 2004
    #4
  5. To clarify, Wayne, Mark's implication is that you can extrude a pline -
    for that matter a circle, ellipse, closed spline, or rectangle without
    having to create a region. By setting the thickness, you are not
    creating a 3D entity, rather an entity some times referred to as 2.5D -
    looks like 3D but only contains 2D properties. It was a neat trick in
    the old days for quickly creating walk-thrus and what not.
    ___________________________
    Mike Tuersley
    CADalyst's AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Feb 19, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.