CAD_Noob Posted July 16, 2022 Posted July 16, 2022 I need help. Do you guys have a working lisp that can copy the Attribute Value of a block in an xref file to a New Attribute Value in the Host file in Field Format? so whenever the value of the attribute in the xref file changes, the value in the host file also changes. Quote
mhupp Posted July 16, 2022 Posted July 16, 2022 (edited) Cant get this working with fields inside of block. maybe the obj id is unique to the block/xref. (defun c:TAG (/ att) (if (setq att (vla-fieldcode (vlax-ename->vla-object (car (nentsel "\nSelect Text with field data: "))))) (entmake (list (cons 0 "TEXT") (cons 10 (getpoint)) (cons 40 (getvar 'DIMTXT)) (cons 1 att) ) ) ) ) Edited July 16, 2022 by mhupp Quote
BIGAL Posted July 17, 2022 Posted July 17, 2022 (edited) I dont think you can get a field the id is dwg dependant. This is a block attribute new dwg Xref obj ID 1742232416 original dwg obj ID 639756208 The only way may be to find the object in the other dwg and read its value using say its handle and OBDX. Maybe xdata attached to the block. Edited July 17, 2022 by BIGAL Quote
CAD_Noob Posted July 18, 2022 Author Posted July 18, 2022 On 7/16/2022 at 10:29 PM, mhupp said: Cant get this working with fields inside of block. maybe the obj id is unique to the block/xref. (defun c:TAG (/ att) (if (setq att (vla-fieldcode (vlax-ename->vla-object (car (nentsel "\nSelect Text with field data: "))))) (entmake (list (cons 0 "TEXT") (cons 10 (getpoint)) (cons 40 (getvar 'DIMTXT)) (cons 1 att) ) ) ) ) Hi thanks for this... just tested the routine. I want to select the item inside the xref (file 1) as an attribute and copy the values to my drawing (file 2) as a field... Quote
mhupp Posted July 18, 2022 Posted July 18, 2022 10 minutes ago, CAD_Noob said: I want to select the item inside the xref (file 1) as an attribute and copy the values to my drawing (file 2) as a field... Yes I understand, and it does that but the obj id is different between the xref and the drawing so it doesn't link to anything. You can use the command on blocks or any field in the drawing and it works just fine. but when using it on a xref doesn't work. Quote
CAD_Noob Posted July 18, 2022 Author Posted July 18, 2022 (edited) On 7/18/2022 at 10:52 AM, mhupp said: Yes I understand, and it does that but the obj id is different between the xref and the drawing so it doesn't link to anything. You can use the command on blocks or any field in the drawing and it works just fine. but when using it on a xref doesn't work. I see.. so it is not possible? Edited July 19, 2022 by CAD_Noob typo Quote
mhupp Posted July 18, 2022 Posted July 18, 2022 42 minutes ago, CAD_Noob said: I see.. so it it not possible? I have come to realize that lisp can do quite a lot but their are limitations. I Don't know maybe? Their is always multiple ways to do things. att = "%<\AcObjProp Object(%<\_ObjId 1167638480>%).Area>%" attlst = ("%<\\AcObjProp Object(%<\\_ObjId " "1167638480" ">%).Area>%") handle = "2F466" when you run that through handnet it returns nil. this is further tested by opening the xref and testing for the handle on the same entity & it returns "2F466" From what I have been reading you need a third data point like txt file or registry. to store the "string" data and then read that file into your current drawing. But that seem clunky and messy. Below code doesn't work on xref either. (defun c:TAG (/ att attlst handle id) (setq att (vla-fieldcode (setq obj (vlax-ename->vla-object (car (nentsel "\nSelect Text with field data: ")))))) (setq attlst (sepnumbers att)) (setq handle (vla-get-handle (vla-objectidtoobject (vla-get-activedocument (vlax-get-acad-object)) (cadr attlst)))) (setq str (strcat (car attlst) (rtos (vla-get-objectid (vlax-ename->vla-object (handent handle))) 2 0) (caddr attlst))) (entmake (list (cons 0 "TEXT") (cons 10 (getpoint)) (cons 40 (getvar 'DIMTXT)) (cons 1 str) ) ) ) ;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-separe-number-and-string-in-the-same-string/m-p/2806136/highlight/true#M292581 (defun sepnumbers (str / tmp char currIsNr lastWasNr rslt) (setq tmp "") (while (/= (setq char (substr str 1 1)) "") (setq currIsNr (wcmatch char "#")) (if (eq currIsNr lastWasNr) (setq tmp (strcat tmp char)) (setq rslt (cons tmp rslt) lastWasNr currIsNr tmp char ) ) (setq str (substr str 2)) ) (setq rslt (reverse (cons tmp rslt))) (cond ((not rslt) '( "")) ((eq (car rslt) "") (cdr rslt)) (T rslt) ) ) 1 1 Quote
CAD_Noob Posted July 20, 2022 Author Posted July 20, 2022 thanks, what I am using currently is Copy or Swap Text by @Lee Mac it works well. but am just thinking if it can be copied as Field.. Thanks for the effort @mhupp Quote
CAD_Noob Posted June 6, 2023 Author Posted June 6, 2023 (edited) hello all, bumping this thread. As mention above I am using @Lee Mac CopySwap Text to copy the values of an attribute in an Xref File (Titleblock) to the value on an Attribute Block (Drawing Title) It's working fine for single copy. Can it be modified so I can copy multiple values and add them into an attribute block as a single value? Example : Source : Text1 Text2 Text3 Destination : Text2 - Text1, Text 3 If it can be copied as Field, it's much better Edited June 6, 2023 by CAD_Noob typo error Quote
Recommended Posts
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.