.NET

Reply
Valued Contributor
dwi_it
Posts: 63
Registered: ‎11-24-2009
Message 1 of 4 (377 Views)

Explode Dimension

377 Views, 3 Replies
02-20-2010 04:21 PM
I'm looking for a way to explode a dimension. I've tried using the Explode() method, but it just results in an eInvalidInput error. Is there a way to explode a dimension into objects?

The reason for this is that I'm using Autocad Architecture and I'm auto-labeling and dimensioning some items I am inserting into the drawing, however the 2d elevation drawing tool in Architecture automatically ignores text and dimensions, so I need a way to explode these into lines so they will show up in the 2d elevation drawings.
Valued Contributor
dwi_it
Posts: 63
Registered: ‎11-24-2009
Message 2 of 4 (377 Views)

Re: Explode Dimension

03-08-2010 04:25 AM in reply to: dwi_it
So, am I to assume that this is not possible?
Active Contributor
calvindale
Posts: 33
Registered: ‎03-11-2010
Message 3 of 4 (199 Views)

Re: Explode Dimension

08-15-2012 09:57 AM in reply to: dwi_it

You could use the BURST command to explode dimenisons. BURST can be executed via the SendCommand() method.

 

For example to explode everything including dimensions, the following snippet works:

 

[CommandMethod("XA")]
public static void ExplodeAllDrawingEntitiesViaSendCommand() {
    "DRAWORDERCTL{0}0{0}BURST{0}ALL{0}{0}EXPLODE{0}ALL{0}{0}DRAWORDERCTL{0}3{0}".SendCommand("\n");
}

 where SendCommand is exposed as an extension method

  

    public static void SendCommand(this string commandFormat, params object[] args) {
        var acadApplication = a.Application.AcadApplication as AcadApplication;
        acadApplication.ActiveDocument.SendCommand(string.Format(commandFormat, args));
    }

 The downside with this approach is that it requires interop with COM dlls.

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

Re: Explode Dimension

08-15-2012 01:05 PM in reply to: dwi_it

Not sure about if this work on your end,

I tested on A2010 all is good for me

    <CommandMethod("dex")> _
    Public Sub TestExplode()
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        ' Select a dimension           
        Dim opts As New PromptEntityOptions(vbLf & "Select a dimension:")
        opts.SetRejectMessage(vbLf & "Must be a dimension...")
        ' opts.AddAllowedClass(GetType(Dimension), False)
        Dim res As PromptEntityResult = ed.GetEntity(opts)
        If res.Status <> PromptStatus.OK Then
            Exit Sub
        End If

        Dim db As Database = doc.Database
        Using trans As Transaction = db.TransactionManager.StartTransaction
                       
            Dim dm As DBObject = trans.GetObject(res.ObjectId, OpenMode.ForRead)
            ed.WriteMessage(vbLf + "{0}", dm.GetType().Name)
            Dim m_dim As Dimension = TryCast(dm, Dimension)
           
            m_dim.UpgradeOpen()
            Dim objs As DBObjectCollection = New DBObjectCollection
            m_dim.Explode(objs)
            Dim btr As BlockTableRecord = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)
            'add exploded object to database
            For Each obj As DBObject In objs
                Dim ent As Entity = TryCast(obj, Entity)
                If TypeOf ent Is MText Then
                    Dim mtx As MText = TryCast(ent, MText)
                    'change textstyle here
                    mtx.TextHeight = mtx.TextHeight * 0.5
                End If
                btr.AppendEntity(ent)
                trans.AddNewlyCreatedDBObject(ent, True)
                ed.WriteMessage(vbLf + "{0}", obj.GetType().Name)
            Next
            'erase dimension
            m_dim.Erase()

            trans.Commit()
        End Using
    End Sub

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Need installation help?

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