.NET

Reply
Active Contributor
dancalgary
Posts: 46
Registered: ‎05-18-2007
Message 1 of 8 (203 Views)

record history doesn't work on creating an extruded hehagon

203 Views, 7 Replies
09-09-2013 06:21 AM

 

Hi,

I am trying to create an extruded hexagon

EVERYTHING WORKS.... BUT:

after the creation of the hexagon the grips are not available even i added the proper code

(Polygon3d.record history = true)

Can somebody help me?

 

 

Thanks

 

See bellow my function.

 

    Public Function extrude_Hexagon(ByVal Centre_point As Point3d, ByVal radius_hexagon As Double, ByVal height_hexagon As Double) As Solid3d
        Try
            Dim ThisDrawing As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim Editor1 As Autodesk.AutoCAD.EditorInput.Editor = ThisDrawing.Editor
            Using Lock1 As DocumentLock = ThisDrawing.LockDocument


                Using Trans1 As Autodesk.AutoCAD.DatabaseServices.Transaction = ThisDrawing.TransactionManager.StartTransaction
                    Dim BTrecord As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord = Trans1.GetObject(ThisDrawing.Database.CurrentSpaceId, OpenMode.ForWrite)



                    Dim Poly1 As New Autodesk.AutoCAD.DatabaseServices.Polyline

                    Dim Point00 As New Point2d(Centre_point.X + radius_hexagon, Centre_point.Y)
                    Dim Point01 As New Point2d(Centre_point.X + radius_hexagon * Cos(PI / 3), Centre_point.Y + radius_hexagon * Sin(PI / 3))
                    Dim Point02 As New Point2d(Centre_point.X - radius_hexagon * Cos(PI / 3), Centre_point.Y + radius_hexagon * Sin(PI / 3))
                    Dim Point03 As New Point2d(Centre_point.X - radius_hexagon, Centre_point.Y)
                    Dim Point04 As New Point2d(Centre_point.X - radius_hexagon * Cos(PI / 3), Centre_point.Y - radius_hexagon * Sin(PI / 3))
                    Dim Point05 As New Point2d(Centre_point.X + radius_hexagon * Cos(PI / 3), Centre_point.Y - radius_hexagon * Sin(PI / 3))

                    Poly1.AddVertexAt(0, Point00, 0, 0, 0)
                    Poly1.AddVertexAt(1, Point01, 0, 0, 0)
                    Poly1.AddVertexAt(2, Point02, 0, 0, 0)
                    Poly1.AddVertexAt(3, Point03, 0, 0, 0)
                    Poly1.AddVertexAt(4, Point04, 0, 0, 0)
                    Poly1.AddVertexAt(5, Point05, 0, 0, 0)
                    Poly1.Closed = True

                    Dim Segments_collection As New DBObjectCollection
                    Poly1.Explode(Segments_collection)


                    Dim Colectie_Regiune As New DBObjectCollection
                    Colectie_Regiune = Autodesk.AutoCAD.DatabaseServices.Region.CreateFromCurves(Segments_collection)

                    Dim Regiunea As New Region
                    Regiunea = Colectie_Regiune(0)
                    Dim Polygon3d As New Solid3d
                    Polygon3d.RecordHistory = True


                    Polygon3d.Extrude(Regiunea, height_hexagon, 0)



                    BTrecord.AppendEntity(Polygon3d)
                    Trans1.AddNewlyCreatedDBObject(Polygon3d, True)



                    Trans1.Commit()
                    Return Polygon3d

                End Using 



            End Using

        Catch ex As Exception

            MsgBox(ex.Message)
        End Try

    End Function

 

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 8 (179 Views)

Re: record history doesn't work on creating an extruded hehagon

09-09-2013 01:27 PM in reply to: dancalgary

Change the logic in your function,

declare object before of "Try" code block,

there is a quick edition:

   Public Function extrude_Hexagon(ByVal Centre_point As Point3d, ByVal radius_hexagon As Double, ByVal height_hexagon As Double) As Solid3d

            Dim ThisDrawing As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim Editor1 As Autodesk.AutoCAD.EditorInput.Editor = ThisDrawing.Editor
            Dim Polygon3d As Solid3d = Nothing
            Try
                Using Lock1 As DocumentLock = ThisDrawing.LockDocument


                    Using Trans1 As Autodesk.AutoCAD.DatabaseServices.Transaction = ThisDrawing.TransactionManager.StartTransaction
                        Dim BTrecord As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord = Trans1.GetObject(ThisDrawing.Database.CurrentSpaceId, OpenMode.ForWrite)

                        Dim Poly1 As New Autodesk.AutoCAD.DatabaseServices.Polyline

                        Dim Point00 As New Point2d(Centre_point.X + radius_hexagon, Centre_point.Y)
                        Dim Point01 As New Point2d(Centre_point.X + radius_hexagon * Math.Cos(Math.PI / 3), Centre_point.Y + radius_hexagon * Math.Sin(Math.PI / 3))
                        Dim Point02 As New Point2d(Centre_point.X - radius_hexagon * Math.Cos(Math.PI / 3), Centre_point.Y + radius_hexagon * Math.Sin(Math.PI / 3))
                        Dim Point03 As New Point2d(Centre_point.X - radius_hexagon, Centre_point.Y)
                        Dim Point04 As New Point2d(Centre_point.X - radius_hexagon * Math.Cos(Math.PI / 3), Centre_point.Y - radius_hexagon * Math.Sin(Math.PI / 3))
                        Dim Point05 As New Point2d(Centre_point.X + radius_hexagon * Math.Cos(Math.PI / 3), Centre_point.Y - radius_hexagon * Math.Sin(Math.PI / 3))

                        Poly1.AddVertexAt(0, Point00, 0, 0, 0)
                        Poly1.AddVertexAt(1, Point01, 0, 0, 0)
                        Poly1.AddVertexAt(2, Point02, 0, 0, 0)
                        Poly1.AddVertexAt(3, Point03, 0, 0, 0)
                        Poly1.AddVertexAt(4, Point04, 0, 0, 0)
                        Poly1.AddVertexAt(5, Point05, 0, 0, 0)
                        Poly1.Closed = True

                        Dim Segments_collection As New DBObjectCollection
                        Poly1.Explode(Segments_collection)


                        Dim Colectie_Regiune As New DBObjectCollection
                        Colectie_Regiune = Autodesk.AutoCAD.DatabaseServices.Region.CreateFromCurves(Segments_collection)
                        Polygon3d = New Solid3d
                        Dim Regiunea As New Region
                        Regiunea = Colectie_Regiune(0)
                        Polygon3d.RecordHistory = True
                        Polygon3d.ShowHistory = True
                        Polygon3d.Extrude(Regiunea, height_hexagon, 0)
                        BTrecord.AppendEntity(Polygon3d)
                        Trans1.AddNewlyCreatedDBObject(Polygon3d, True)

                        Trans1.Commit()

                    End Using

                End Using

            Catch ex As Exception
                Polygon3d = Nothing
                MsgBox(ex.Message)
            End Try
            Return Polygon3d
        End Function

 

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Active Contributor
dancalgary
Posts: 46
Registered: ‎05-18-2007
Message 3 of 8 (164 Views)

Re: record history doesn't work on creating an extruded hehagon

09-09-2013 03:40 PM in reply to: Hallex

I have changed as per your instructions but no luck

my hexagon is still without history

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 8 (153 Views)

Re: record history doesn't work on creating an extruded hehagon

09-09-2013 11:00 PM in reply to: dancalgary

Mine is have one, see piccy

Show_history.png

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Active Contributor
dancalgary
Posts: 46
Registered: ‎05-18-2007
Message 5 of 8 (137 Views)

Re: record history doesn't work on creating an extruded hehagon

09-10-2013 07:59 AM in reply to: Hallex

vb.net code creates the red extruded hexagon

the yellow one i did it manualy

I think I have an error in my code

I should try to use the polyline?

 

 

hexagon - no grips.JPG

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 6 of 8 (130 Views)

Re: record history doesn't work on creating an extruded hehagon

09-10-2013 09:09 AM in reply to: dancalgary

Yes you can, instead of exploding a polyline

use this code snip:

                       Dim Segments_collection As New DBObjectCollection
                        
                        Segments_collection.Add(Poly1)

                        Dim Colectie_Regiune As New DBObjectCollection

                        Colectie_Regiune = Autodesk.AutoCAD.DatabaseServices.Region.CreateFromCurves(Segments_collection)

		'Rest code is the same

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Active Contributor
dancalgary
Posts: 46
Registered: ‎05-18-2007
Message 7 of 8 (116 Views)

Re: record history doesn't work on creating an extruded hehagon

09-10-2013 03:00 PM in reply to: Hallex
    Public Function Creaza_Hexagon(ByVal Centre_point As Point3d, ByVal radius_hexagon As Double, ByVal height_hexagon As Double) As Solid3d
        Dim ThisDrawing As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim Editor1 As Autodesk.AutoCAD.EditorInput.Editor = ThisDrawing.Editor
        Dim Polygon3d As Solid3d = Nothing

        Try

            Using Lock1 As DocumentLock = ThisDrawing.LockDocument


                Using Trans1 As Autodesk.AutoCAD.DatabaseServices.Transaction = ThisDrawing.TransactionManager.StartTransaction
                    Dim BTrecord As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord = Trans1.GetObject(ThisDrawing.Database.CurrentSpaceId, OpenMode.ForWrite)



                    Dim Poly1 As New Autodesk.AutoCAD.DatabaseServices.Polyline

                    Dim Point00 As New Point2d(Centre_point.X + radius_hexagon, Centre_point.Y)
                    Dim Point01 As New Point2d(Centre_point.X + radius_hexagon * Cos(PI / 3), Centre_point.Y + radius_hexagon * Sin(PI / 3))
                    Dim Point02 As New Point2d(Centre_point.X - radius_hexagon * Cos(PI / 3), Centre_point.Y + radius_hexagon * Sin(PI / 3))
                    Dim Point03 As New Point2d(Centre_point.X - radius_hexagon, Centre_point.Y)
                    Dim Point04 As New Point2d(Centre_point.X - radius_hexagon * Cos(PI / 3), Centre_point.Y - radius_hexagon * Sin(PI / 3))
                    Dim Point05 As New Point2d(Centre_point.X + radius_hexagon * Cos(PI / 3), Centre_point.Y - radius_hexagon * Sin(PI / 3))

                    Poly1.AddVertexAt(0, Point00, 0, 0, 0)
                    Poly1.AddVertexAt(1, Point01, 0, 0, 0)
                    Poly1.AddVertexAt(2, Point02, 0, 0, 0)
                    Poly1.AddVertexAt(3, Point03, 0, 0, 0)
                    Poly1.AddVertexAt(4, Point04, 0, 0, 0)
                    Poly1.AddVertexAt(5, Point05, 0, 0, 0)
                    Poly1.Closed = True

                    Poly1.TransformBy(Matrix3d.Displacement(Poly1.GetPointAtParameter(0).GetVectorTo(New Point3d(Centre_point.X + radius_hexagon, Centre_point.Y, Centre_point.Z))))

                    Dim Segments_collection As New DBObjectCollection
                    Segments_collection.Add(Poly1)


                    Dim Colectie_Regiune As New DBObjectCollection
                    Colectie_Regiune = Autodesk.AutoCAD.DatabaseServices.Region.CreateFromCurves(Segments_collection)

                    Dim Regiunea As New Region
                    Regiunea = Colectie_Regiune(0)
                    Polygon3d = New Solid3d
                    Polygon3d.RecordHistory = True
                    Polygon3d.ShowHistory = True

                    Polygon3d.Extrude(Regiunea, height_hexagon, 0)



                    BTrecord.AppendEntity(Polygon3d)
                    Trans1.AddNewlyCreatedDBObject(Polygon3d, True)



                    Trans1.Commit()


                End Using 




            End Using

        Catch ex As Exception
            Polygon3d = Nothing
            MsgBox(ex.Message)
        End Try
        Return Polygon3d
    End Function

 

I still have the same problem

I do have just 1 grip

 

 

 

hexagon - no grips.JPG

 

This one is manually created

 

 

hexagon - no grips.JPG

 

See code used above.

 

 

Distinguished Contributor
junoj
Posts: 116
Registered: ‎02-26-2009
Message 8 of 8 (92 Views)

Re: record history doesn't work on creating an extruded hehagon

09-10-2013 09:39 PM in reply to: dancalgary

It appears that not all solids are created equally. If you ‘list’ both solids (manual & code) you will see that the manual solid is classified by CAD as SOLID TYPE = Extrusion, and it has an EXTRUSION HEIGHT property.

 

The one created by code is just a regular solid (if you union two Extrusions you get a regular solid like the one created by code).

 

If you need more grips you can hold down the Ctrl button and select the solid with a window (lower right to upper left) you will see additional grips available on both Solids (manual and code), the only grip missing on the ‘code’ solid is the ‘Height’ grip.

 

I am currently using AutoCAD 2008. Perhaps AutoDesk has added the Height property to the newer version of AutoCAD or created a New Extrusion type class in the new AutoCAD. I don’t have the new CAD to check.

 

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.