.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
JLS2012-1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
(visual studio 2010 c# and AutoCAD 2010 )
I`m trying to create a new layer with ARGB color but SetRGB doesn`t work this way.
Any idea. thank you.
// Color is a System.Drawing.Color
private static void NewLayer(string layerName, Color layerColor)
{
LY_Rutas = gbl_doc.Layers.Add(layerName);
LY_Rutas.TrueColor.SetRGB(layerColor.R, layerColor.G, layerColor.B);
}
Solved! Go to Solution.
Re: JLS2012-1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Color in AutoCAD is not a Drawing.Color
Add to your using region:
using.AutoCAD.Colors;
~'J'~
C6309D9E0751D165D0934D0621DFF27919
Re: JLS2012-1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanx for the reply.
Now, when i add this line
using.AutoCAD.Colors;
i got the next error.
**************************************************
System.BadImageFormatException was unhandled
Message=No se puede cargar el archivo o ensamblado 'acdbmgd, Version=18.1.0.0, Culture=neutral, PublicKeyToken=null' ni una de sus dependencias. Se ha intentado cargar un programa con un formato incorrecto.
Source=DrivingAutoCAD
FileName=acdbmgd, Version=18.1.0.0, Culture=neutral, PublicKeyToken=null
FusionLog==== Información de estado anterior al enlace ===
LOG: Usuario = Juan-VAIO\Juan
LOG: DisplayName = acdbmgd, Version=18.1.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Trabajo/Palmatools/INECO/PEIF/Pruebas_V
LOG: PrivatePath inicial = NULL
Ensamblado de llamada : DrivingAutoCAD, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Este enlace empieza en el contexto de carga default.
LOG: Utilización del archivo de configuración de la aplicación: C:\Trabajo\Palmatools\INECO\PEIF\Pruebas_VC2010\Pr
LOG: Utilizando el archivo de configuración de host:
LOG: Utilizando el archivo de configuración del equipo en C:\Windows\Microsoft.NET\Framework\v4.0.30319\conf
LOG: La directiva no se está aplicando a la referencia en este momento (enlace de ensamblado privado, personalizado, parcial o basado en la ubicación).
LOG: Intento de descarga de la nueva dirección URL file:///C:/Trabajo/Palmatools/INECO/PEIF/Pruebas_V
ERR: Error al completar la instalación del ensamblado (hr = 0x8007000b). Finalizó la búsqueda.
StackTrace:
en DrivingAutoCAD.Form1.button1_Click(Object sender, EventArgs e)
en System.Windows.Forms.Control.OnClick(EventArgs e)
en System.Windows.Forms.Button.OnClick(EventArgs e)
en System.Windows.Forms.Button.OnMouseUp(MouseEventAr
en System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.ButtonBase.WndProc(Message& m)
en System.Windows.Forms.Button.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.O
en System.Windows.Forms.Control.ControlNativeWindow.W
en System.Windows.Forms.NativeWindow.DebuggableCallba
en System.Windows.Forms.UnsafeNativeMethods.DispatchM
en System.Windows.Forms.Application.ComponentManager.
en System.Windows.Forms.Application.ThreadContext.Run
en System.Windows.Forms.Application.ThreadContext.Run
en System.Windows.Forms.Application.Run(Form mainForm)
en DrivingAutoCAD.Program.Main() en C:\Trabajo\Palmatools\INECO\PEIF\Pruebas_VC2010\Pr
en System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
en Microsoft.VisualStudio.HostingProcess.HostProc.Run
en System.Threading.ThreadHelper.ThreadStart_Context(
en System.Threading.ExecutionContext.Run(ExecutionCon
en System.Threading.ExecutionContext.Run(ExecutionCon
en System.Threading.ThreadHelper.ThreadStart()
InnerException:
**************************************************
Are there another way to do something like this, and that works?
int r = 255;
int g = 0;
int b = 0;
AcadLayer LY_Rutas = gbl_doc.Layers.Add("PruebaCAD");
LY_Rutas.TrueColor.SetRGB(r,g,b);
thanx again
Re: JLS2012-1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Here is what I would to create new layer
[CommandMethod("myLay", CommandFlags.Modal | CommandFlags.Redraw)]
public void CreateLayer()
{
string layerName = "LY_Rutas";
ObjectId layerId = ObjectId.Null;
byte r = 176;
byte g = 37;
byte b = 28;
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
// Get the layer table from the drawing and open for write
LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForWrite);
if (lt.Has(layerName))
{
layerId = lt[layerName];
if (layerId.IsErased)
{
LayerTableRecord ltr = (LayerTableRecord)tr.GetObject(layerId, OpenMode.ForWrite, true);
ltr.Erase(false);
}
}
else
{
// Create new layer table record
LayerTableRecord ltr = new LayerTableRecord();
// Add some properties
ltr.Name = layerName;
ltr.LinetypeObjectId = db.ContinuousLinetype;
ltr.LineWeight = LineWeight.LineWeight030;
ltr.Color = Color.FromRgb(r, g, b);
layerId = lt.Add(ltr);
// Append layer to database
tr.AddNewlyCreatedDBObject(ltr, true);
tr.Commit();
}
}
}Using your function try this way, not tested
AcadLayer LY_Rutas = gbl_doc.Layers.Add("PruebaCAD");
//change linetype
LY_Rutas.Linetype = strLtype;
//change entity color
AcadAcCmColor acCol = LY_Rutas.TrueColor;
//1. change color RGB
acCol.ColorMethod = AcColorMethod.acColorMethodByRGB;
acCol.SetRGB(255,255,0);
//2. change color index etc...
//acCol.ColorMethod = AcColorMethod.acColorMethodByACI;
//acCol.ColorIndex = (AcColor)140;
LY_Rutas.TrueColor = acCol;
//release AcadAcCmColor object
acCol = null;
~'J'~
C6309D9E0751D165D0934D0621DFF27919
Re: JLS2012-1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanx very much.
it works perfectly.
![]()
Re: JLS2012-1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Glad to help
Cheers ![]()
~'J'~
C6309D9E0751D165D0934D0621DFF27919
