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

How to change scale using .NET or C#

7 REPLIES 7
Reply
Message 1 of 8
dip_nik
4761 Views, 7 Replies

How to change scale using .NET or C#

Good evening all,

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

Thanks,
7 REPLIES 7
Message 2 of 8
djonio
in reply to: dip_nik

Maybe the attached will help.
r,
dennis
Message 3 of 8
dip_nik
in reply to: dip_nik

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
Message 4 of 8
dip_nik
in reply to: dip_nik

Hi djonio

Thank's for reply.

how to change selected entity scale Only

Thanks,
Message 5 of 8
Hallex
in reply to: dip_nik

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
dip_nik
in reply to: dip_nik

Hi hallex ,

Thanks again
Thank you so muchhhhhhhhh for the reply.

Have a nice Day
Message 7 of 8
Hallex
in reply to: dip_nik

Glad if that worked
Have a nice day

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 8 of 8

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.

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