Author Topic: Recalculate fields after changing source object value  (Read 2103 times)

0 Members and 1 Guest are viewing this topic.

AngelKostadinov

  • Newt
  • Posts: 30
Recalculate fields after changing source object value
« on: February 19, 2016, 03:52:00 AM »
Hello guys!

I'm using Teigha .NET SWIG libraries to edit drawings and recently stuck with a problem...
I have a question related to fields and more precisely, how to update (evaluate) fields manually (with .net api) across the whole drawing.

Consider following use-case:
- There are 2 block references appended to model space;
- Each reference points to different block record;
- Each block reference 'has' a single attribute reference within;
- 1st attribute reference has "foo" as a string value;
- 2nd attribute reference has a field, pointing to 1st attribute text value;
- Opening this drawing in AutoCAD, it displays the 2 block references with "foo" text on both;
- In AutoCAD, If we change the source value ot "bar" and trigger some action that makes AutoCAD to evaluate fields, then "bar" appears on the 2nd place; As such action we could consider saving, plotting, regeneration and etc..

Here is my problem:
I'm opening the drawing with Teigha libraries, changing the "source" text value and extracting a PDF file from it. After Opening the result PDF file, I see that field is not evaluated and 2nd attribute contains the old value of "foo" instead of "bar". So, what action should I take in order to make fields to recompute?



Am I supposed to iterate through all db objects and to search for OdDbField and to call evaluate() method?

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Recalculate fields after changing source object value
« Reply #1 on: February 19, 2016, 05:30:50 AM »
Hi,

Try either of these;
Code - C#: [Select]
  1.  ed.Regen(); // ed = Editor
  2.  
Code - C#: [Select]
  1.  trA.TransactionManager.QueueForGraphicsFlush(); // trA = Transaction
  2.  

Hope it would work for you.

AngelKostadinov

  • Newt
  • Posts: 30
Re: Recalculate fields after changing source object value
« Reply #2 on: February 19, 2016, 07:05:15 AM »
Thank you for your post!

In AutoCAD or BricsCAD there is such method available in Editor class, but I'm not using any of those platforms. I'm using Open Design Alliance's Teigha .NET SWIG generated components and there is no such thing as Editor or Transaction.

Teigha .NET SWIG
« Last Edit: February 22, 2016, 01:37:54 AM by AngelKostadinov »

CADbloke

  • Bull Frog
  • Posts: 342
  • Crash Test Dummy
Re: Recalculate fields after changing source object value
« Reply #3 on: February 21, 2016, 08:55:40 PM »
I'm using Open Design Alliance's Teigha .NET SWIG generated components and there is no such thing as Editor or Transaction.

https://www.opendesign.com/members/memberfiles/teigha_dot_net
Your link is members-only. We can't see it.

One of the reasons I walked away from the ODA .NET library is that the SWIG-generated API is not compatible with .NET code for other platforms. Their Teigha "Classic" .net platform maintains that compatibility but it feels doomed for extinction. RealDwg worked out to be the same price (for me), easier to re-use code in other platforms and has a longer life expectancy so I went with that. </opinion>

August 2018:
Quote
Their Teigha "Classic" .net platform maintains that compatibility but it feels doomed for extinction.
Wrong, it's still around and not going anywhere. I built tvCAD on RealDwg. I would have a much better look at Teigha if I were to start it now.
« Last Edit: August 01, 2018, 07:47:27 PM by CADbloke »

AngelKostadinov

  • Newt
  • Posts: 30
Re: Recalculate fields after changing source object value
« Reply #4 on: February 22, 2016, 02:30:35 AM »
I'm just a developer and not participate in strategic decisions making  :-)
Link is updated.
I'm going to test following scenario: open database - edit - save - dispose database - open again with
Code: [Select]
TD_Db.oddbEvaluateFields(db, 255) which means
Code: [Select]
EvalContext.kOpen | EvalContext.kSave| EvalContext.kPlot | EvalContext.kOpen | EvalContext.kEtransmit | EvalContext.kRegen | EvalContext.kDemand | EvalContext.kPreview