Count fields

Count fields

msarqui
Collaborator Collaborator
1.235 Vistas
9 Respuestas
Mensaje 1 de 10

Count fields

msarqui
Collaborator
Collaborator

Hi guys,

 

It would be possible to count FIELDS in a string?

I mean, I would like to know if a string has a FIELD and how many?

 

Thanks,

Marcelo

0 Me gusta
Soluciones aceptadas (1)
1.236 Vistas
9 Respuestas
Respuestas (9)
Mensaje 2 de 10

devitg
Advisor
Advisor
upload , a DWG sample.
0 Me gusta
Mensaje 3 de 10

msarqui
Collaborator
Collaborator

Attached a sample with two fields in a text.

Thanks.

0 Me gusta
Mensaje 4 de 10

devitg
Advisor
Advisor
Hi Msarqui , please upload the dwg with the entytis related to the fields,
in 2007 please .

--

Nombre: Gabriel
Apellido: CALÓS
SERVICIOS MECATRÓNICOS ®
DUCASSE 948
CÓRDOBA
(X5000FVF)
ARGENTINA
TEL 054-351-471-0256
CEL 0351-156-192177
devitg@gmail.com

"la victoria es propicia a los que se preparan"

AMAT VICTORIA CURAM
0 Me gusta
Mensaje 5 de 10

msarqui
Collaborator
Collaborator

Here it goes.

0 Me gusta
Mensaje 6 de 10

devitg
Advisor
Advisor
Solución aceptada

Test it

 

 

(defun C:field-in-text   ()
(VL-LOAD-COM)

(setq texto (car( entsel "\n select mtext ")))

  (setq string (cdr(assoc 1 (entget texto))))
  
(setq texto-obj (VLAX-ENAME->VLA-OBJECT texto ))
  (if (vla-FieldCode texto-obj)
                (setq texto+field  (vla-FieldCode texto-obj))
                     )
;; "See detail page %<\\AcObjProp Object(%<\\_ObjId -8375544>%).Name>%\\PSee colors page A00\\PSee support page %<\\AcObjProp Object(%<\\_ObjId 0>%).Name>%" 




;; helper function

;;cuenta los caracteres iguales en un texto es case sensitive
;; count equal character set in a string   

(DEFUN STR-COUNT  (STR TOK / RES)
  (SETQ RES 0)
  (WHILE (> (STRLEN STR) 0)
    (IF (= (STR-POS STR TOK) 1)
      (PROGN
        (SETQ RES (1+ RES))
        (SETQ STR (SUBSTR STR (1+ (STRLEN TOK))))
        )
      (PROGN
        (SETQ STR (SUBSTR STR 2))
        )
      )
    )
  RES
  )
;;;;;-*******************************************************************************************************************************
;;modo de uso  
;;;(str-ltrimset "\\String" "\\") ;_=> "String"
;;indica la posici[on de un texto en otro
;; mark the  pattern position in a string   
;;;;;-********************************************
(DEFUN STR-POS  (STR C / I L LS LC) ;_ 01
  (SETQ I 1)
  (SETQ LS (STRLEN STR))
  (SETQ LC (STRLEN C))
  (SETQ L (1+ (- LS LC)))
  (WHILE (AND (<= I L) (/= (SUBSTR STR I LC) C))
    (SETQ I (1+ I))
    )
  (IF (<= I L)
    I
    )
  )
  (setq fiel-qty (str-count  texto+field  "%<\\AcObjProp"))
)
0 Me gusta
Mensaje 7 de 10

msarqui
Collaborator
Collaborator

Many thanks Gabriel,

 

I will do some tests and I will return later with the results.

0 Me gusta
Mensaje 8 de 10

msarqui
Collaborator
Collaborator

Hi Gabriel,

 

It is working very well.
Now I am starting to expand the possibilities and I am trying to use with a multiline attribute using NENTSEL for a selection. But, it seems that the vla-FieldCode is not working with attributes.
Do you have an ideia for that?

Please, see attached file.

 

Thanks

Marcelo

0 Me gusta
Mensaje 9 de 10

devitg
Advisor
Advisor
I'm out off home now, wiil test when backhome

--

Nombre: Gabriel
Apellido: CALÓS
SERVICIOS MECATRÓNICOS ®
DUCASSE 948
CÓRDOBA
(X5000FVF)
ARGENTINA
TEL 054-351-471-0256
CEL 0351-156-192177
devitg@gmail.com

"la victoria es propicia a los que se preparan"

AMAT VICTORIA CURAM
0 Me gusta
Mensaje 10 de 10

devitg
Advisor
Advisor
An attribute TEXT STRING do not have the FIELD as method. Maybe the way, is to BURST , an Expresstool, and then you can get the MTEXT vla-FieldCode .To keep the original inserted block, it must be copy , and BURST the copy, count the FIELD , and after it erase the "bursted" entities. First you must get the INSERT boundingbox , and SSGET all , but not the INSERT , and erase all at the Selection Set. A main concern if there is only a INSERT inside the boundingBOX
0 Me gusta