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

Explode Dimension

5 REPLIES 5
Reply
Message 1 of 6
dwi_it
1218 Views, 5 Replies

Explode Dimension

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.
5 REPLIES 5
Message 2 of 6
dwi_it
in reply to: dwi_it

So, am I to assume that this is not possible?
Message 3 of 6
calvindale
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.

Message 4 of 6
Hallex
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
Message 5 of 6
whamlin
in reply to: dwi_it

EXPLMODE = 0

 

😄

 

Message 6 of 6
mszanto
in reply to: dwi_it

The eInvalidInput error occurs on newly created dimensions. The following worked for me.

1. Make sure the dimension has been appended and added (AppendEntity and AddNewlyCreatedDBObject) and has a valid ObjectId.
2. Execute 
Transaction.TransactionManager.QueueForGraphicsFlush().

3. Explode

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