How to change scale using .NET or C#

How to change scale using .NET or C#

Anonymous
Not applicable
5,353 Views
7 Replies
Message 1 of 8

How to change scale using .NET or C#

Anonymous
Not applicable
Good evening all,

I want to change a scale of drawing (all entity) & save it
Help me I am using AutoCAD 2010

Thanks,
0 Likes
5,354 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Maybe the attached will help.
r,
dennis
0 Likes
Message 3 of 8

Anonymous
Not applicable
Hi djonio ,
Thanks a lot for reply it very useful

I am able to scale the view but I am facing problem to set origin
Please help

Thanks
0 Likes
Message 4 of 8

Anonymous
Not applicable
Hi djonio

Thank's for reply.

how to change selected entity scale Only

Thanks,
0 Likes
Message 5 of 8

Hallex
Advisor
Advisor
Here is an quick xample how to do it

{code}
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.GraphicsInterface;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

............................................
// credits Tony Tanzillo

public static void Scale(ObjectId id, Point3d basept, double scale)
{
Matrix3d transform = Matrix3d.Scaling(scale,basept);

Database db = id.Database;

using (Transaction tr = db.TransactionManager.StartTransaction())
{
try
{
Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);

if (ent != null)
{
ent.TransformBy(transform);
}

tr.Commit();

}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
AcadApp.ShowAlertDialog(ex.Message);
}

}
}


[CommandMethod("SCE")]
public static void ScaleSelected()
{
Document doc = AcadApp.DocumentManager.MdiActiveDocument;

Editor ed = doc.Editor;

PromptEntityOptions peo = new PromptEntityOptions("\nSelect an Entity: ");

PromptEntityResult res = ed.GetEntity(peo);

if (res.Status != PromptStatus.OK)
return;

PromptPointOptions ppo = new PromptPointOptions("\nPick Base Point: ");

PromptPointResult pres = ed.GetPoint(ppo);

if (pres.Status != PromptStatus.OK)
return;

PromptDoubleOptions pdo = new PromptDoubleOptions("\nSpecify Scale Factor: ");

PromptDoubleResult dres = ed.GetDouble(pdo);

if (dres.Status != PromptStatus.OK)
return;

ObjectId id = res.ObjectId;

Point3d basept =pres.Value;

double scale = dres.Value;

Scale(id, basept, scale);

}
{code}

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 6 of 8

Anonymous
Not applicable
Hi hallex ,

Thanks again
Thank you so muchhhhhhhhh for the reply.

Have a nice Day
0 Likes
Message 7 of 8

Hallex
Advisor
Advisor
Glad if that worked
Have a nice day

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 8 of 8

Anonymous
Not applicable

Does anyone know how to let the user scale the objects?  I need users to be able to see exactly how their scale is going to turn out.

0 Likes