.NET

Reply
Contributor
dip_nik
Posts: 18
Registered: ‎11-26-2007
Message 1 of 8 (1,365 Views)

How to change scale using .NET or C#

1365 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
djonio
Posts: 105
Registered: ‎12-29-2005
Message 2 of 8 (1,371 Views)

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
dip_nik
Posts: 18
Registered: ‎11-26-2007
Message 3 of 8 (1,365 Views)

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
dip_nik
Posts: 18
Registered: ‎11-26-2007
Message 4 of 8 (1,365 Views)

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*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 5 of 8 (1,364 Views)

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
dip_nik
Posts: 18
Registered: ‎11-26-2007
Message 6 of 8 (1,363 Views)

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*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 7 of 8 (1,364 Views)

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
vampirefromtheITcave2
Posts: 72
Registered: ‎07-21-2009
Message 8 of 8 (1,275 Views)

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
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.