Revision Cloud

Revision Cloud

SRSDS
Advisor Advisor
950 Views
4 Replies
Message 1 of 5

Revision Cloud

SRSDS
Advisor
Advisor

I want to cloud a polyline.

This works :

 

    <CommandMethod("RevisionCloud")>
    Public Shared Sub RevisionCloud()
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
        Dim ids As List(Of ObjectId) = New List(Of ObjectId)()
        Using tr As Transaction = db.TransactionManager.StartTransaction()
            Dim bt As BlockTable = TryCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
            Dim ms As BlockTableRecord = TryCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
            Using c As Circle = New Circle(New Point3d(0, 0, 0), Vector3d.ZAxis, 20)
                Dim circleId As ObjectId = ms.AppendEntity(c)
                tr.AddNewlyCreatedDBObject(c, True)
                ids.Add(circleId)
            End Using
            tr.Commit()
        End Using
        Dim ss As SelectionSet = SelectionSet.FromObjectIds(ids.ToArray)
        ed.Command("_.REVCLOUD", "", "O", "", ss, "")
    End Sub

 

but when I try to implement it I get

Autodesk.AutoCAD.Runtime.Exception: 'eInvalidInput'

on the line ed.Command("_.REVCLOUD", "", "O", "", ss, "")

I can't work out out what the problem might be.

 

Alternatively, does anyone have code that will cloud a polyline from a set of vertices?

0 Likes
Accepted solutions (1)
951 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

Hi,

You should pass the circle ObjectId to the command instead of a selection set.

 

[CommandMethod("REVISIONCLOUD")]
public static void RevisionCloud()
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var db = doc.Database;
    var ed = doc.Editor;
    ObjectId circleId;
    using (var tr = db.TransactionManager.StartTransaction())
    {
        var modelSpace = (BlockTableRecord)tr.GetObject(
            SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
        var circle = new Circle(Point3d.Origin, Vector3d.ZAxis, 20.0);
        circleId = modelSpace.AppendEntity(circle);
        tr.AddNewlyCreatedDBObject(circle, true);
        tr.Commit();
    }
    ed.Command("_.REVCLOUD", "_Object", circleId, "_No");
}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

SRSDS
Advisor
Advisor

Hi Gile,

Both those work but your's is better as calling ed.Command("_.REVCLOUD", "", "O", "", ss, "")

on a SelectionSet doesn't work too well as the "_.REVCLOUD" command only handles one entity at a time. ie only clouds one of the entities in the ss.

 

I still seem to have a problem with applying it in my project which has me utterly confused.

I still get a Autodesk.AutoCAD.Runtime.Exception: 'eInvalidInput'  on the line

ed.Command("_.REVCLOUD", "_Object", circleId, "_No");

 

The only difference I can think of is that code is being triggered by modifying a textbox control in a pallete.

Not sure if this makes sense but I tried getting the objects handle when it was created then converting it back to an objectID before the editor command to make sure it was the same entity. Grasping at straws but that checked out.    

 

 

0 Likes
Message 4 of 5

_gile
Consultant
Consultant
Accepted solution

If you call this method from a Palette (i.e. in application context) you should call it using:

Application.DocumentManager.MdiActiveDocument.SendStringToExecute("REVISIONCLOUD ", false, false, false);

so that you let AutoCAD switch to document context and lock the document.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 5

SRSDS
Advisor
Advisor

Thank you again. 

0 Likes