.NET

.NET

Reply
Contributor
18 Posts
0 Kudos
Registered: ‎11-26-2007
Post 1 of 8

How to change scale using .NET or C#

1400 Views, 7 Replies
01-22-2010 04:26 AM
Good evening all,

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

Thanks,
Distinguished Contributor
105 Posts
1 Kudo
Registered: ‎12-29-2005
Post 2 of 8

Re: How to change scale using .NET or C#

01-22-2010 07:56 AM in reply to: dip_nik
Maybe the attached will help.
r,
dennis
Contributor
18 Posts
0 Kudos
Registered: ‎11-26-2007
Post 3 of 8

Re: How to change scale using .NET or C#

01-24-2010 11:34 PM 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
Contributor
18 Posts
0 Kudos
Registered: ‎11-26-2007
Post 4 of 8

Re: How to change scale using .NET or C#

01-28-2010 03:22 AM in reply to: dip_nik
Hi djonio

Thank's for reply.

how to change selected entity scale Only

Thanks,
*Expert Elite*
1,569 Posts
171 Kudos
Registered: ‎10-08-2008
Post 5 of 8

Re: How to change scale using .NET or C#

01-28-2010 09:41 AM 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
Contributor
18 Posts
0 Kudos
Registered: ‎11-26-2007
Post 6 of 8

Re: How to change scale using .NET or C#

01-28-2010 08:06 PM in reply to: dip_nik
Hi hallex ,

Thanks again
Thank you so muchhhhhhhhh for the reply.

Have a nice Day
*Expert Elite*
1,569 Posts
171 Kudos
Registered: ‎10-08-2008
Post 7 of 8

Re: How to change scale using .NET or C#

01-28-2010 11:02 PM in reply to: dip_nik
Glad if that worked
Have a nice day

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
72 Posts
0 Kudos
Registered: ‎07-21-2009
Post 8 of 8

Re: How to change scale using .NET or C#

10-11-2010 05:41 AM in reply to: Hallex

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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!