Question

ACAD [Writing DWG] - Save polygon handle as an xdata for that polygon

  • 5 December 2014
  • 6 replies
  • 3 views

Badge
Hi  

 

 

 

I am trying to read a .dwg file and after some modification writing it back to .dwg. I have some polygons and I need to save the handle ("autocad_entity_handle") of each polygon as an xdata for that polygon and in a predefined position ("extended_data_list{9}"), however each time and just in time of writing, ACAD Writer generates a new handle ! 

 

 

 

I appreciate if anybody can help me with that. 

 

 

 

Many thanks 

 

Regards 

 

 

Hani

6 replies

Badge +3

 

Autocad wil generate the handles itself (afaik...).

 

 

But on forums for autocad and or python, visualbasi etc. for autocad there are examples of manipulating this.

 

"You can replace an existing entity by a new one with ObjectARX and the handle can be retained using function AcDbObject::handOverTo(). The new entity will have the same handle and AcDbObjectId as the old one."

 

 

and also from autodesk:

 

"The handent function retrieves the name of an entity with a specific handle. As with entity names, handles are unique within a drawing. However, an entity's handle is constant throughout its life. AutoLISP applications that manipulate a specific database can use handent to obtain the current name of an entity they must use. You can use the DDMODIFY command to get the handle of a selected object."

 

 

"In one particular editing session, this code fragment might display the following:

 

 

<Entity name: 60004722>

 

 

In another editing session with the same drawing, the fragment might display an entirely different number. But in both cases the code would be accessing the same entity."

 

 

...so is it usefull to do what u say you want to i wonder.
Badge
Hi Augustina,

 

 

Many thanks for your answer.

 

my goal is to not use Autocad or Lisp; Using python could be an intersting solution however my real goal is to use only FME for manupolating my data. Is there any possibility in FME to only modify an attribute of an object (ex. xdata of a polygon) without regenerating the object (which will be resulted in regenerating the handle)?

 

 

I will be glad if you kindy reply to my question.

 

 

Thanks again

 

 

Hani

 

 
Badge +3
With fme you can write  autocad data and xtended data too.

 

But this will not nescesarily change or influence the dwg. 

 

Check the fme great readers and writer book dwg section.

 

 

Entity handles cannot be changed or manipulated using fme solely (afaik), as it has to write the file at some time using the dwg writer wich will regenerate it.

 

 

You could do this tho using python using a a pythoncaller (or tcl) , as long as you not use a dwg-writer at the end of the workbench, else it will rewrite it again.

 

 

(i hav'nt done this myself, so you know..)

 

 

 

 
Badge
Dear Augustina,

 

 

This is exactly what I am looking for : How can I modify a .dwg file (add some xdata to a polygons) and save the modification without writing back the .dwg file?

 

 

Again many thanks for your help

 

Regards,

 

 

Hani   
Badge +3
Hi,

 

 

Check this page of the fme dwg Readers and Writers 20214:

 

http://docs.safe.com/fme/html/FME_ReadersWriters/Default.htm#autocad_od/Writer_Directives.htm%3FTocPath%3DFME%20Readers%20and%20Writers%20(formats%20supported%20by%20FME%202014)%7CAutodesk%20AutoCAD%20Map%203D%20Object%20Data%20Reader%2FWriter%7CMapping%20File%20Directives%7C_____2

 

 

Maybe you can control it after all using FME by creating a DEF file for the writer by

 

 

[autocad_od_entity_key_attr autocad_od_entity_key]

 

 

 

 

 
Badge
Many thanks however I couldn't set the "autocad_entity_handle" field value :(

 

 

I need to set the value for "autocad_entity_handle" using values from another field inside FME.

 

 

Thanks

Reply