Jump to content

Recommended Posts

Posted

While checking for dxf group codes in a text with a field inside I've found some inside it, wich i looked further. For example, i would directly get

 

Select entity((-1 . ) (0 . "TEXT") (5 . "602428") (102 . "{ACAD_XDICTIONARY") (360 . ) (102 . "}") (330 . ) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "est.Texto") (6 . "Continuous") (370 . 0) (100 . "AcDbText") (10 3811.01 -3721.81 0.0) (40 . 0.15) (1 . "1.05") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Leg0.15") (71 . 0) (72 . 1) (11 3811.22 -3721.73 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 2))

 

And when looking for what was inside code group 360 I'd go further and find other properties.

 

So I've partially written the following to reach a field code path

 

 

(defun c:dump3 ( / a e o s x texto tipodepeca z y ent ent2 ent3 ent4)
   (if (setq s (ssget "_:L" '((0 . "TEXT")) ))
       (repeat (setq i (sslength s))
           (setq e (ssname s (setq i (1- i)))
                 x (entget e)
                 ent (entget(cdr (assoc 360 x)))
			  ent2 (entget(cdr (assoc 360 ent)))
			  ent3 (entget(cdr (assoc 360 ent2)))
			  ent4 (entget(cdr (assoc 360 ent3)))
           )
		
		(prin1 ent4) ;shows groups with field expression paths

(entmod (subst '(331 . "<Entity name: 7ffff06b620>") (assoc 331 ent4) ent4)); attempt to edit the codegroup 331 on entity "4 levels below"
	)
)
(princ)
)
(princ)

 

I've tried to change the entity on groupcode 331, but i'm getting the following error everytime:

 

error: bad DXF group: (331 . "")

 

Any hint?

Posted

Entity names are pointers to locations within the drawing database, they are not strings and cannot be represented as literal data in code; entity names (and hence Object IDs) are also not persistent between drawing sessions, but are allocated ad hoc.

Posted

Thanks, I've just closed my drawing, re-opened, and yes its true, the id changes. The vla-fieldcode can only read the current code. Which means I'm out of ways to edit the table linked to the field. Do you have any idea how to do this Lee Mac? (no need to code for me, just point me in the direction)

Posted

Retrieve the Object ID of the new object to be referenced by the field code, rebuild the field code using the new Object ID, and then update the content of the object which is to contain the field using vla-put-textstring to automatically rebuild the associated field dictionaries.

Posted

So I would get the ID from codegroup -1 of the table in that session,

 

then rebuild the field as in

 

(entmod (subst '(2 . "\\AcExpr (Table(%<\\_ObjIdx 0>%).C3) \\f \"%lu2%pr3\"") (assoc 2 ent4) ent4))

 

replacing (%%) by the decimal value of the number in codegroup -1

 

and then update the content of the text object? When i perform a list on the text object I get the following:

 

Select entity((-1 . ) (0 . "TEXT") (5 . "61BFA6") (102 . "{ACAD_XDICTIONARY") (360 . ) (102 . "}") (330 . ) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "est.Texto") (6 . "Continuous") (370 . 0) (100 . "AcDbText") (10 3811.01 -3721.81 0.0) (40 . 0.15) (1 . "1.05") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Leg0.15") (71 . 0) (72 . 1) (11 3811.22 -3721.73 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 2))

 

Nothing here seems a text string i could replace to finalize your steps

Posted

The first 2 steps are working, but when I save and re-open the drawing, #### shows up instead of the value I had before. So I'm missing just that last step. What kind of string should I apply? It's on the text object for sure, but, what string it is? I mean literally, I have no idea what string I should place on a text object to simulate a field

Posted

Done..

 

(defun c:dump6 ( / a e o s x texto tipodepeca z y ent ent2 ent3 ent4 obj tabela count count2)
   
(setq count 2)
    ;(setq tabela (entget (entsel "\nEscolher tabela")))
   (if (setq s (ssget "_:L" '((0 . "TEXT")) ))

       (repeat (setq i (sslength s))
           (setq e (ssname s (setq i (1- i)))
                 x (entget e)
                 ent (entget(cdr (assoc 360 x)))
			  ent2 (entget(cdr (assoc 360 ent)))
			  ent3 (entget(cdr (assoc 360 ent2)))
			  ent4 (entget(cdr (assoc 360 ent3)))
           )
	  
	  (setq count (1+ count))
	             ;o codigo da table é convertido de hexa para decimal e colocado aqui
		(entmod (subst (cons 2 (strcat "\\AcExpr (Table(8796085420640).B" (itoa count) ") \\f \"%lu2%pr3\"")) (assoc 2 ent4) ent4))
		(prin1 count)
		;FAZER REGEN ANTES DE SAIR
	)
)
(princ)
)
(princ)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...