Author Topic: acedRedraw .NET Equivalent  (Read 5454 times)

0 Members and 1 Guest are viewing this topic.

Nathan Taylor

  • Guest
acedRedraw .NET Equivalent
« on: September 14, 2006, 02:49:58 AM »
Is there a .NET equivalent of the ARX acedRedraw function?

Regards - Nathan

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: acedRedraw .NET Equivalent
« Reply #1 on: September 14, 2006, 02:00:47 PM »
What about P/Invoke this function?

Nathan Taylor

  • Guest
Re: acedRedraw .NET Equivalent
« Reply #2 on: September 14, 2006, 07:42:09 PM »
What about P/Invoke this function?
If it is not exposed I will just use the way I have been doing it in VBA which is to use the VisualLisp Activex Module to evaluate the lisp function.

Alexander Rivilis

  • Bull Frog
  • Posts: 214
  • Programmer from Kyiv (Ukraine)
Re: acedRedraw .NET Equivalent
« Reply #3 on: September 15, 2006, 04:19:51 AM »
This function can be used in next ways:
1) Redraw screen
2) Show/hide entity -> Entity.Visible  = true (or false)
3) Highlight/Unhighlight entity -> Entity.Highlight(..)/Entity.Unhighlight(...)
Code: [Select]
#define ACADR16

using System ;
using System.Runtime.InteropServices ;
using Autodesk.AutoCAD.Runtime ;
using Autodesk.AutoCAD.ApplicationServices ;
using Autodesk.AutoCAD.EditorInput ;
using Autodesk.AutoCAD.DatabaseServices ;
using Autodesk.AutoCAD.Geometry ;

[assembly: CommandClass(typeof(Rivilis.Redraw))]

namespace Rivilis
{
  public class Redraw
  {
    [System.Security.SuppressUnmanagedCodeSecurity]
    [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
    private static extern Int32 acedRedraw(long [] name, Int32 mode);
#if ACADR16
    [DllImport("acdb16.dll", CallingConvention=CallingConvention.Cdecl, EntryPoint="?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")] 
#elif ACADR17
    [DllImport("acdb17.dll", CallingConvention=CallingConvention.Cdecl, EntryPoint="?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")] 
#endif
    private static extern int acdbGetAdsName(long [] name, ObjectId objId);

    [CommandMethod("MyRedraw")]
    static public void MyRedraw()
    {
      acedRedraw(null, 1);
    }
    // Highlight entity
    [CommandMethod("HlEnt")]
    static public void HlEnt()
    {
      PromptEntityOptions entityOpts = new PromptEntityOptions("\nSelect entity: ");
      PromptEntityResult rc = Application.DocumentManager.MdiActiveDocument.Editor.GetEntity(entityOpts);
      if (rc.Status == PromptStatus.OK)
      {
        long [] ent = new long [] { 0, 0};
        acdbGetAdsName(ent,rc.ObjectId);
        acedRedraw(ent, 3);
      }
    }
    // Unhighlight entity
    [CommandMethod("UlEnt")]
    static public void UlEnt()
    {
      PromptEntityOptions entityOpts = new PromptEntityOptions("\nSelect entity: ");
      PromptEntityResult rc = Application.DocumentManager.MdiActiveDocument.Editor.GetEntity(entityOpts);
      if (rc.Status == PromptStatus.OK)
      {
        long [] ent = new long [] { 0, 0};
        acdbGetAdsName(ent,rc.ObjectId);
        acedRedraw(ent, 4);
      }
    }
  }
}
« Last Edit: September 15, 2006, 05:20:28 AM by Alexander Rivilis »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: acedRedraw .NET Equivalent
« Reply #4 on: September 15, 2006, 05:42:05 AM »
Looks nice Alex' ... developed on a theme that is becoming familiar .. thanks.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Nathan Taylor

  • Guest
Re: acedRedraw .NET Equivalent
« Reply #5 on: October 03, 2006, 02:04:04 AM »
For anyone using VB.NET.

Code: [Select]
    <System.Security.SuppressUnmanagedCodeSecurity()> _
    <System.Runtime.InteropServices.DllImport("acad.exe", CallingConvention:=System.Runtime.InteropServices.CallingConvention.Cdecl)> _
    Private Shared Function acedRedraw(ByVal name As Long(), ByVal mode As Integer) As Integer
    End Function

    <CommandMethod("MyRedraw")> _
    Public Sub MyRedraw()
        acedRedraw(Nothing, 1)
    End Sub

Regards - Nathan