Author Topic: PInvoke acdbEntUpd  (Read 12917 times)

0 Members and 1 Guest are viewing this topic.

Jeff_M

  • King Gator
  • Posts: 4037
  • C3D user & customizer
Re: PInvoke acdbEntUpd
« Reply #30 on: March 06, 2016, 04:52:32 PM »
Kerry, sorry to dig up this old thread but I've just had an occasion to find a way to update a single object. My Google search led me here. After a bit of work to change your last solution to work in Acad2014 or 2015, it runs without error but also doesn't update the entity.

Background for my needs....I've been coding for Civil3d 2016 lately. I found that I have some tools to edit Aecc objects, but they were not updating until a REGEN was issued. I didn't want to add a full REGEN due to these drawings usually being fairly large and a regen is often a bit slow. In 2016 that isn't a problem, because I found the Acad.Utils.RegenEntity() method which updates the objects just as I needed. But then I opened the projects for C3D2014 & 2015 (we don't support any of the older versions with new code) and was greeted with the old RegenEntity() not found error. Hit Google looking for something I could do, found this thread and it's sister over on the Autodesk .NET forum.

So, back to my current issue with this code. It seems like it should do what I need, but it is not updating the entities like the 2016 RegenEntity() method does. I also tried Tony's mention of changing the entity's layer to the same layer, which also doesn't update the object. Did this work to update objects for you?

Jeff_M

  • King Gator
  • Posts: 4037
  • C3D user & customizer
Re: PInvoke acdbEntUpd
« Reply #31 on: March 06, 2016, 06:08:49 PM »
Well, I stumbled upon a solution for the older versions that was too easy....just toggle the entity's Visible property off then back on, entity updates perfectly.

kdub

  • Mesozoic keyThumper
  • SuperMod
  • Swamp Rat
  • Posts: 1438
  • class keyThumper<T>:ILazy<T>
Re: PInvoke acdbEntUpd
« Reply #32 on: March 06, 2016, 09:44:22 PM »
Well, I stumbled upon a solution for the older versions that was too easy....just toggle the entity's Visible property off then back on, entity updates perfectly.

great !

called Kerry in my other life

Sometimes the question is more important than the answer.

I don't really work crazy hours . . I just live at UTC + 12.00
#ridesober

kdub

  • Mesozoic keyThumper
  • SuperMod
  • Swamp Rat
  • Posts: 1438
  • class keyThumper<T>:ILazy<T>
Re: PInvoke acdbEntUpd
« Reply #33 on: March 06, 2016, 10:04:32 PM »
< .. > In 2016 that isn't a problem, because I found the Acad.Utils.RegenEntity() method which updates the objects just as I needed. < .. >

Give them another 10 years, they may produce a (nearly) complete API :)
called Kerry in my other life

Sometimes the question is more important than the answer.

I don't really work crazy hours . . I just live at UTC + 12.00
#ridesober

Jeff H

  • Needs a day job
  • Posts: 6108
Re: PInvoke acdbEntUpd
« Reply #34 on: March 06, 2016, 11:59:57 PM »
< .. > In 2016 that isn't a problem, because I found the Acad.Utils.RegenEntity() method which updates the objects just as I needed. < .. >
If you need it in 2015 looks like you can pinvoke acdbQueueForRegen

RegenEntity()
Code: [Select]
public static unsafe void RegenEntity(ObjectId entId)
{
    AcDbObjectId id;
    *((long*) &id) = 0L;
    *((long*) &id) = entId.OldIdPtr.ToInt64();
    acdbQueueForRegen((AcDbObjectId modopt(IsConst)*) &id, 1);
}

 

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: PInvoke acdbEntUpd
« Reply #35 on: March 07, 2016, 07:42:45 AM »
< .. > In 2016 that isn't a problem, because I found the Acad.Utils.RegenEntity() method which updates the objects just as I needed. < .. >

Give them another 10 years, they may produce a (nearly) complete API :)


I doubt it.
Revit 2019, AMEP 2019 64bit Win 10

Jeff_M

  • King Gator
  • Posts: 4037
  • C3D user & customizer
Re: PInvoke acdbEntUpd
« Reply #36 on: March 07, 2016, 12:31:11 PM »

If you need it in 2015 looks like you can pinvoke acdbQueueForRegen

RegenEntity()
Code: [Select]
public static unsafe void RegenEntity(ObjectId entId)
{
    AcDbObjectId id;
    *((long*) &id) = 0L;
    *((long*) &id) = entId.OldIdPtr.ToInt64();
    acdbQueueForRegen((AcDbObjectId modopt(IsConst)*) &id, 1);
}

 
Yes, Jeff, I found that as well. Passing just the ObjectId did nothing, passing the ObjectId and 1 crashed Autocad (could be I was not implementing it correctly). That's when I kept looking for something else and found a post that mentioned the Visible property could be a solution.