66 DwgArcEntity ,
77 DwgAttachmentPoint ,
88 DwgAttdefEntity ,
9+ DwgAttribEntity ,
910 DwgBoundaryPath ,
1011 DwgBoundaryPathEdge ,
1112 DwgBoundaryPathEdgeType ,
@@ -138,6 +139,8 @@ export class LibreEntityConverter {
138139 return this . convertArc ( entity_tio , commonAttrs )
139140 } else if ( fixedtype == Dwg_Object_Type . DWG_TYPE_ATTDEF ) {
140141 return this . convertAttdef ( entity_tio , commonAttrs )
142+ } else if ( fixedtype == Dwg_Object_Type . DWG_TYPE_ATTRIB ) {
143+ return this . convertAttrib ( entity_tio , commonAttrs )
141144 } else if ( fixedtype == Dwg_Object_Type . DWG_TYPE_CIRCLE ) {
142145 return this . convertCircle ( entity_tio , commonAttrs )
143146 } else if (
@@ -389,7 +392,7 @@ export class LibreEntityConverter {
389392 ) . data as number
390393 const isReallyLocked = libredwg . dwg_dynapi_entity_value (
391394 entity ,
392- 'is_locked_in_block '
395+ 'is_really_locked '
393396 ) . data as number
394397 // TODO: double check whether 'mtext_type' is 'mtextFlag'
395398 const mtextFlag = libredwg . dwg_dynapi_entity_value ( entity , 'mtext_type' )
@@ -418,6 +421,58 @@ export class LibreEntityConverter {
418421 }
419422 }
420423
424+ private convertAttrib (
425+ entity : Dwg_Object_Entity_Ptr ,
426+ commonAttrs : DwgCommonAttributes
427+ ) : DwgAttribEntity {
428+ const libredwg = this . libredwg
429+
430+ const text = this . convertTextBase ( entity )
431+ const tag = libredwg . dwg_dynapi_entity_value ( entity , 'tag' ) . data as string
432+ const flags = libredwg . dwg_dynapi_entity_value ( entity , 'flags' )
433+ . data as number
434+ const fieldLength = libredwg . dwg_dynapi_entity_value ( entity , 'field_length' )
435+ . data as number
436+ const lockPositionFlag = libredwg . dwg_dynapi_entity_value (
437+ entity ,
438+ 'lock_position_flag'
439+ ) . data as number
440+ const duplicateRecordCloningFlag = libredwg . dwg_dynapi_entity_value (
441+ entity ,
442+ 'keep_duplicate_records'
443+ ) . data as number
444+ // TODO: double check whether 'mtext_type' is 'mtextFlag'
445+ const mtextFlag = libredwg . dwg_dynapi_entity_value ( entity , 'mtext_type' )
446+ . data as number
447+ const isReallyLocked = libredwg . dwg_dynapi_entity_value (
448+ entity ,
449+ 'is_really_locked'
450+ ) . data as number
451+ const alignmentPoint = libredwg . dwg_dynapi_entity_value (
452+ entity ,
453+ 'alignment_pt'
454+ ) . data as DwgPoint2D
455+
456+ return {
457+ type : 'ATTRIB' ,
458+ ...commonAttrs ,
459+ text : text ,
460+ tag : tag ,
461+ flags : flags ,
462+ fieldLength : fieldLength ,
463+ lockPositionFlag : ! ! lockPositionFlag ,
464+ duplicateRecordCloningFlag : ! ! duplicateRecordCloningFlag ,
465+ mtextFlag : mtextFlag ,
466+ isReallyLocked : ! ! isReallyLocked ,
467+ numberOfSecondaryAttrs : 0 , // TODO: libredwg doesn't support it yet.
468+ secondaryAttrsHardId : '0' , // TODO: libredwg doesn't support it yet.
469+ alignmentPoint : { ...alignmentPoint , z : 0 } ,
470+ annotationScale : 1 , // TODO: Set the correct value
471+ attrTag : '' , // TODO: Set the correct value
472+ mtext : this . convertEmbeddedMText ( entity , 'ATTDEF_mtext' )
473+ }
474+ }
475+
421476 private convertCircle (
422477 entity : Dwg_Object_Entity_Ptr ,
423478 commonAttrs : DwgCommonAttributes
@@ -919,6 +974,21 @@ export class LibreEntityConverter {
919974 'extrusion'
920975 ) . data as DwgPoint3D
921976
977+ const attrib_ptr_array = libredwg . dwg_entity_insert_get_attribs ( entity )
978+ const attribs : DwgAttribEntity [ ] = [ ]
979+ attrib_ptr_array . forEach ( object_ptr => {
980+ const entity = libredwg . dwg_object_to_entity ( object_ptr )
981+ const entity_tio = libredwg . dwg_object_to_entity_tio ( object_ptr )
982+ if ( entity && entity_tio ) {
983+ // Get values of the common attributes of ATTRIB entity
984+ const commonAttrs = this . getCommonAttrs ( entity )
985+ const fixedtype = libredwg . dwg_object_get_fixedtype ( object_ptr )
986+ if ( fixedtype == Dwg_Object_Type . DWG_TYPE_ATTRIB ) {
987+ attribs . push ( this . convertAttrib ( entity_tio , commonAttrs ) )
988+ }
989+ }
990+ } )
991+
922992 // TODO: convert block attributes
923993 return {
924994 type : 'INSERT' ,
@@ -933,7 +1003,8 @@ export class LibreEntityConverter {
9331003 rowCount : rowCount ,
9341004 columnSpacing : columnSpacing ,
9351005 rowSpacing : rowSpacing ,
936- extrusionDirection : extrusionDirection
1006+ extrusionDirection : extrusionDirection ,
1007+ attribs : attribs
9371008 }
9381009 }
9391010
0 commit comments