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

Regen entity

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
danny.boy.1
3485 Views, 9 Replies

Regen entity

Hello!

 

I have one problem with regen entity.

 

Is there any way to apply regen only for one entity, I unfortunately

did'n find any method for this...

 

Best regards,

Danijel

9 REPLIES 9
Message 2 of 10
kdub_nz
in reply to: danny.boy.1

As far as I recall there is none.

 

You can use QueueForGraphicsFlush() to have the graphic display prior to calling Comit

.. not sure if that will help you 🙂


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 3 of 10
danny.boy.1
in reply to: danny.boy.1

Hello KerryBrown :-)!

 

I need regent entity because, I have on specific entity xdata.

When user copy entity, I need to regen it, because depending on it

function worlddraw (for custom entity).

 

I found on objectarx function

 

acdbEntUpd() //regen object

 

But, but don't know is there in .net api something like this.

 

Thank you!

 

Best regards,

Danijel

Message 4 of 10
kdub_nz
in reply to: danny.boy.1

Danijel,

I've tried to pInvoke acdbEntUpd()

but have hit a wall. I'm obviously doing something wrong ...

[assembly: CommandClass(typeof(KdubTesting.TestCommands))]

namespace KdubTesting
{
    // CodeHimBelongaKdub Jun 2008 
    public partial class Kdub_API
    {
        //==================================================================================

        [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
        public static extern int acdbEntUpd(long adsName);
        /*
       * If acdbEntUpd() succeeds, it returns RTNORM  ( 5100 )
       * otherwise,                it returns RTERROR.(-5001 )
       * When acdbEntUpd() fails, it sets the system variable ERRNO to a value
       * that indicates the reason for the failure. 
       */ 
        //==================================================================================

        [DllImport("acdb18.dll", CallingConvention = CallingConvention.Cdecl,
        EntryPoint = "?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")]
        public extern static ErrorStatus acdbGetAdsName(out long objName, ObjectId objId );

        /*
         * Acad::ErrorStatus acdbGetAdsName(
         *      ads_name& objName, 
         *      AcDbObjectId obj
         * );
         * This function fills in objName with the ads_name that corresponds to the objId object ID.
         * Returns Acad::eOk if successful. 
         * If objId is 0, then Acad::eNullObjectId is returned.
      */ 
        //==================================================================================

    }
    // CodeHimBelongaKdub Jun 2008 
    public partial class TestCommands
    {
        [CommandMethod("EntUpd")]
        static public void TestacdbEntUpd()
        {
            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            PromptEntityResult res = ed.GetEntity("\nSelect an entity to Regen:");
            ObjectId id = res.ObjectId;
            long adsName;
            ErrorStatus es;

            AcadApp.SetSystemVariable("ERRNO", 0);

            using(Transaction tr = db.TransactionManager.StartTransaction())
            {
                es = Kdub_API.acdbGetAdsName(out adsName, id);

                ed.WriteMessage("\n adsName is {0} ", adsName);
                ed.WriteMessage("\n ErrorStatus is {0} ", es);

                int apiReturn = Kdub_API.acdbEntUpd(adsName); 

                ed.WriteMessage("\n api acdbEntUpd_Return is {0} ", apiReturn);
                ed.WriteMessage("\n System variable ERRNO  is {0} ", AcadApp.GetSystemVariable("ERRNO"));

                tr.Commit();
            }
            ed.WriteMessage("\n Complete: System variable ERRNO  is {0} ", AcadApp.GetSystemVariable("ERRNO"));
        }
    }
}

 

This is the result I'm getting :

Command: errno
Enter new value for ERRNO <0>:

Command: entupd

Select an entity to Regen:
 adsName is 9158139860942894088
 ErrorStatus is OK
 api acdbEntUpd_Return is -5001
 System variable ERRNO  is 5
 Complete: System variable ERRNO  is 5

Command: errno
Enter new value for ERRNO <2>:

The acdbEntUpd generates an ERRNO of 5
When the routine returns to AutoCAD, the ERRNO command from the commandLine reports 2.

The 'Scrambled' name for acdbGetAdsName is the same in acdb17.dll 32bit  and acdb18.dll 32bit ... so my DllImports should be suitable for AC 2007-AC2011 ( once I get the bug sorted. )


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 5 of 10
Anonymous
in reply to: kdub_nz

Ignoring the platform-specific entrypoint issue,

I think you need to declare any ads_name parameter

as an out parameter. Or you can use double[]

 

Your declaration for acdbEntUpd() should have

an 'out' parameter.

 

You can also open the entity for write, and just

assign its LayerId property to the same value it

currently has, and that should also cause it to

update.

Message 6 of 10
kdub_nz
in reply to: Anonymous

Thanks Tony,

Weve been discussing this at theSwamp

http://www.theswamp.org/index.php?topic=33741.msg391098#msg391098

I missed that ads_name needed to be an array of longs not a long.

Interesting procedure with the  LayerId property !!

I'll do some more testing 🙂

 


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 7 of 10
danny.boy.1
in reply to: danny.boy.1

Hello Smiley Happy!

 

I wish you many thanks for this invaluable assistance!!!

 

Yours knowledge of autocad api is amazing for me Smiley Surprised!!!

 

...

 

In attachment is class, litle modified and convertet to vb.net from

http://www.theswamp.org/index.php?topic=33741.msg391098#msg391098

 

Code:

 

Imports Autodesk.AutoCAD.DatabaseServices
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput

Public Class EntUpdate

    ' ARX signature:
    ' int acdbEntUpd( const ads_name ent);
    <DllImport("acad.exe", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="acdbEntUpd")> _
    Public Shared Function acdbEntUpd(ByVal ent As Long()) As Integer
    End Function

    ' ARX signature:
    ' Acad::ErrorStatus acdbGetAdsName(ads_name& objName, AcDbObjectId objId);
    <DllImport("acdb18.dll", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")> _
    Public Shared Function acdbGetAdsName(ByVal objName As Long(), ByVal objId As ObjectId) As Integer
    End Function

    <CommandMethod("TEST1")> _
    Public Shared Sub CmdTest()
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor

        Dim per As PromptEntityResult = ed.GetEntity(vbLf & "Select object: ")
        If per.Status <> PromptStatus.OK Then
            Return
        End If
        Dim objName As Long() = New Long() {0, 0}
        acdbGetAdsName(objName, per.ObjectId)
        acdbEntUpd(objName)
    End Sub

    Public Shared Sub CmdTest(ByVal objID As ObjectId)
        Dim objName As Long() = New Long() {0, 0}
        acdbGetAdsName(objName, objID)
        acdbEntUpd(objName)
    End Sub


End Class

 

 

 

Best regards,

Danijel

Message 8 of 10
Anonymous
in reply to: kdub_nz

Oops.

 

Sorry, did I say 'double[]' ? Smiley Indifferent

 

Of course, I meant long[], not double[].

 

I think this is what you would use:

 

static extern int acdbEntUpd( out Int64 ename );

 

 

 

Message 9 of 10
kdub_nz
in reply to: Anonymous


@Anonymous wrote:

 

Sorry, did I say 'double[]' ? Smiley Indifferent

 

Of course, I meant long[], not double[].

 

Yep, I knew what you meant  Smiley Wink Thanks.

I still need to find time to fully test the 'out' for myself.


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Message 10 of 10
kdub_nz
in reply to: kdub_nz

Tony,

The 'out' option worked fine { but you knew that 🙂 }

Thanks for the help.

 

Danijel ,

I've updated theSwamp files with a new test routine;

... however, something like this may be a little more practical.
I'd be happy to have someone seriously test it.

 

using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

[assembly: CommandClass(typeof(KdubTesting.TestCommands))]

namespace KdubTesting
{
    // CodeHimBelongaKdub Jun 2008 
    public partial class TestCommands
    {
        const string ACAD_EXE = "Acad.exe";
        const short RTNORM = 5100;
        const short RTERROR = -5001;
        //===================================================================================
        // ARX signature:
        // Acad::ErrorStatus acdbGetAdsName(ads_name& objName, AcDbObjectId objId);
        [DllImport("acdb18.dll", CallingConvention = CallingConvention.Cdecl,
            EntryPoint = "?acdbGetAdsName@@YA?AW4ErrorStatus@Acad@@AAY01JVAcDbObjectId@@@Z")]
        public static extern ErrorStatus acdbGetAdsName(out long adsName, ObjectId id);
        /*
        * Parameters
        *  ads_name& objName    Output ads_name  
        *  AcDbObjectId objId   Input object ID  
        *
        * This function fills in objName with the ads_name that 
        * corresponds to the objId object ID.
        * Returns Acad::eOk if successful. 
        * If objId is 0, then Acad::eNullObjectId is returned.
        */
        //===================================================================================
        // ARX signature:
        // int acdbEntUpd( const ads_name ent);
        [DllImport(ACAD_EXE, CallingConvention = CallingConvention.Cdecl,
            EntryPoint = "acdbEntUpd")]
        public static extern int acdbEntUpd(out long adsName);
        /*
        * If acdbEntUpd() succeeds, it returns RTNORM  ( 5100 )
        * otherwise,                it returns RTERROR.(-5001 )
        * When acdbEntUpd() fails, it sets the system variable ERRNO to a value
        * that indicates the reason for the failure. 
        */
        //===================================================================================
        //===================================================================================
        [CommandMethod("Test0614b")]
        static public void Test0614b_acdbEntUpd_withBoolTestMethod()
        {
            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;

            PromptEntityResult per = ed.GetEntity("\nSelect object: ");
            if(per.Status != PromptStatus.OK)
            {
                ed.WriteMessage("\n Nothing Selected");
                return;
            }
            ObjectId id = per.ObjectId;
            if( EntityUpdate(id))
                System.Windows.Forms.MessageBox.Show( "Entity Updates sucessfully", "Test0614b");
            else
                System.Windows.Forms.MessageBox.Show( "It hit the fan", "Test0614b");
        }
        //===================================================================================
        public static bool EntityUpdate(ObjectId id)
        {
            long adsName;
            if(acdbGetAdsName(out adsName, id) != ErrorStatus.OK)
                return false;
            return (acdbEntUpd(out adsName) == RTNORM);
        }
        //===================================================================================
     }
}

 

 

 

 


// Called Kerry in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

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