.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

record history doesn't work on creating an extruded hehagon

7 REPLIES 7
Reply
Message 1 of 8
dancalgary
533 Views, 7 Replies

record history doesn't work on creating an extruded hehagon

 

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

 

 

7 REPLIES 7
Message 2 of 8
Hallex
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
Message 3 of 8
dancalgary
in reply to: Hallex

I have changed as per your instructions but no luck

my hexagon is still without history

Message 4 of 8
Hallex
in reply to: dancalgary

Mine is have one, see piccy

Show_history.png

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 8
dancalgary
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

Message 6 of 8
Hallex
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
Message 7 of 8
dancalgary
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.

 

 

Message 8 of 8
junoj
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.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost