Creating solid fill areas trough c#

Creating solid fill areas trough c#

Anonymous
Not applicable
986 Views
2 Replies
Message 1 of 3

Creating solid fill areas trough c#

Anonymous
Not applicable

Hi All,

 

I've created a c# dll that query a database in order to discover several data on a total of 800 register.

For each register received I try to create a solid fill area against an autocad document and database.

The drawing remains a while doing the operation but when it concludes only a few solid fill areas are designed.

There is any limit of objects do be created?

 

Thanks and regards,

 

Joaquim Pinto

0 Likes
987 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

As far is i know there are no limits.

I have a working hatch module that works with a Selection Set with multiple filter settings.

 

This is what i use in VB, i think you can rewrite it to C#:

Public Sub Arceer(ByVal oDXF As String, ByVal oVertaal As String, ByVal oPatern As String, ByVal oRed As String, ByVal oGreen As String, ByVal oBlue As String)
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acDocEd As Editor = acDoc.Editor
        Dim acCurDb As Database = acDoc.Database
        Dim acTypValAr(1) As TypedValue
        acTypValAr.SetValue(New TypedValue(DxfCode.Start, "*POLYLINE"), 0)
        acTypValAr.SetValue(New TypedValue(DxfCode.LayerName, oDXF), 1)
        Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)
        Dim acSSPrompt As PromptSelectionResult
        On Error GoTo Einde
        acSSPrompt = acDocEd.SelectAll(acSelFtr)
        Dim acSSet As SelectionSet = acSSPrompt.Value
        If acSSPrompt.Value.Count > 0 Then
            MaakLayer(oVertaal, True, oRed, oGreen, oBlue)
            For Each oSel As SelectedObject In acSSet
                Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
                    Dim acBlkTbl As BlockTable
                    acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
                    Dim acBlkTblRec As BlockTableRecord
                    acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
                    Dim acObjIdColl As ObjectIdCollection = New ObjectIdCollection()
                    acObjIdColl.Add(oSel.ObjectId)
                    Dim acHatch As Hatch = New Hatch()
                    acBlkTblRec.AppendEntity(acHatch)
                    acTrans.AddNewlyCreatedDBObject(acHatch, True)
                    acHatch.SetDatabaseDefaults()
                    acHatch.SetHatchPattern(HatchPatternType.PreDefined, oPatern)
                    acHatch.Associative = False
                    acHatch.AppendLoop(HatchLoopTypes.Outermost, acObjIdColl)
                    acHatch.Layer = oVertaal
                    acHatch.EvaluateHatch(True)
                    Dim Dot As DrawOrderTable = acTrans.GetObject(acBlkTblRec.DrawOrderTableId, OpenMode.ForWrite)
                    acBlkTblRec.DowngradeOpen()
                    Dim oHatchID As ObjectIdCollection = New ObjectIdCollection()
                    oHatchID.Add(acHatch.ObjectId)
                    Dot.MoveToBottom(oHatchID)
                    acTrans.Commit()
                End Using
            Next
        End If
Einde:
    End Sub

 The variables sended to the procedure:

oDXF = The Layer where the polylines are on

oVertaal = The layer where the hatch would be on (created by MaakLayer)

oPatern = Paternname of the hatch (solid, ansi31,...)

oRed,oGreen,oBlue = the RGB color of the hatch, you can change the code easely to use a normal color.

 

Hatches draweorder are send to back.

 

Hope this one helps.

 

Grtz

 

Peter

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks Peter for your reply.

I was away from this project but already managed to solve the problem I had. The database query was not working probably that’s why I have these issues with the number of solids.

Now it's working fine.

Thanks for your help.

Regards,

 

Joaquim

0 Likes