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

vb.net select ALL

3 REPLIES 3
Reply
Message 1 of 4
kcimos
2056 Views, 3 Replies

vb.net select ALL

I'm trying to write a vb.net routine to automate this:

 

I need to move, rotate, and scale EVERY object in a drawing.

 

I assume I need to create a selection set of ALL objects.

I can't see how to do this, I know how to have a user select polylines, or whatever.

I don't see a need for user interaction here, I just want ALL the objects into a selection set that I can process.

 

OR

 

is there another way of doing this transform operation on ALL objects without creating a selection set?

 

In autocad it would just be: "Align", enter, "ALL" enter, enter, pick 4 points. done

"Scale" enter "P" enter "1/12" enter.

 

donre.

(i've tried using synchronous command sending, but I can't get that to work, so I figured the 3d transform matrix was the wasy to go)

3 REPLIES 3
Message 2 of 4
norman.yuan
in reply to: kcimos

You can use Editor.SelectAll() with or without filter to select all or targeting entities for your transformation process. You can surely achieve the effect as you described as what user see how AutoCAD does it. For example shown in following pseudo-code:

 

public void MoveAllEntity()

{

    Document dwg=Application.DocumentManager.MdiActiveDocument;

    Editor ed=dwg.Editor;

 

    PromptSelectionResult res=ed,SelectAll();

    if (res.Status==PromptStatus.OK)

    {

        ObjectId[] selectedIds=res.Value.GetObjectIds();

       

        //Here you may want to highlight all the selected entities

        //so the code running is more like native AutoCAD command

 

        //Ask user to pick based point,

        //you may allow user to hit Enter for a default base point

        Point3d basePt=SelectBasePoint(ed);

 

        //Ask user for point to move to

        //or a distance and direction (angle)

       Point3d movetOPt=SelectDestination(ed);

 

        Matrix3d mt=DiefineMyTransformMatris(basePt, moveToPt) //define an Matrix3d for move

 

        //Do the move

        using (Transaction tran=....)

        {

            foreach (ObjectId id in selectedIds)

            {

                //Open the entity and then

 

                ent.TransformedBy(mt);

 

                //Unhighlight the entity if you highlighted previously

            }

            tran.commit()

        }

    }

}

 

As you can see, the only user interrection needed is to pick 2 points.With Editor.SelectAll(), there is no need for user interaction to select entities.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4
kcimos
in reply to: norman.yuan

OK, thanks, that is fine & would work I'm sure, except that I'm actually getting the points from a file as this routine is to work on multiple drawings (& also do so without actually opening the files (not necessary but nice).

 

I guess I need to just iterate all items (geometry/text) in the dwg database via the BlockTable & then in this case for me, the model space BlockTableRecord

Message 4 of 4
norman.yuan
in reply to: kcimos

If you want to do the transformation in side database, then you cannot use Editor.SelectAll(), because there is not Editor for side database.

 

Yes, if you only target entities in ModelSpace (or given layout in paperspace), you just get the space BlockTableRecord and then loop through all entities in that space.

Norman Yuan

Drive CAD With Code

EESignature

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