vla-put-tagstring problem

vla-put-tagstring problem

Patrick.De.Neef
Advocate Advocate
2,035 Views
10 Replies
Message 1 of 11

vla-put-tagstring problem

Patrick.De.Neef
Advocate
Advocate

Hello All

 

need a little bit of help here

Trying to modify the attribute tag name via vla-put-tagstring

the following code does everything I want it to do, except the vla-put-tagstring

Actually it removes the attribute prompt (please see screendumps)

I must be overlooking something basic

Please don't tell me that the code looks awful, I know 😓, it is not optimized, just tried to divide it up into every possible single piece to see what is going wrong

 

 

(vlax-for obj
    (vla-item (vla-get-Blocks (vla-get-Document blockobj))
      (if (vlax-property-available-p blockobj 'EffectiveName)
        (vla-get-EffectiveName blockobj)
        (vla-get-Name blockobj)
      )
    )
	
    (if (eq "AcDbAttributeDefinition" (vla-get-ObjectName obj))
		(progn
			(setq Blk_Tag (vla-get-TagString obj))
			(setq Blk_XYZ (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint obj))))
			(setq Blk_Prm (vla-get-PromptString obj))
			(setq Blk_X (rtos(car Blk_XYZ) 2 0 ))
			(setq Blk_Y (rtos(cadr Blk_XYZ) 2 0 ))
			(princ "Blk_Tag = ")(princ Blk_Tag)(princ "\t")(princ "Blk_X = ")(princ Blk_X)(princ "\t")(princ "Blk_Y = ")(princ Blk_Y)(princ "\t")(princ "Blk_Prm = ")(princ Blk_Prm)(princ "\n")
			(foreach line Exl_Attrib_Info
				(if (/= (car line) "Column1")
				(progn
				(setq Exl_Tag (nth 0 line))
				(setq Exl_Prm (nth 1 line))
				(setq Exl_X (nth 2 line))
				(setq Exl_Y (nth 3 line))
				(setq Exl_NewTag (nth 4 line))
					(if (and ( = Blk_tag Exl_Tag)
							 ( = Blk_Prm Exl_Prm)
							 ( = Blk_X Exl_X)
							 ( = Blk_Y Exl_Y))
					(progn
					(princ "found correct settings \t")(princ "Old Prompt = ")(princ Blk_Prm)(princ "\t")(princ "New Tag Will be = ")(princ Exl_NewTag)(princ "\n")
					(setq result (vla-put-tagstring obj Exl_NewTag))
					(princ "result = ")(princ result)(princ "\n")
					))
				))
			)
				
	))
;		
 )

 

 

 

(the variable Exl_Attrib_Info comes from an excel file and is correct)

result.pngstart.png

 

thanks in advance

Patrick

0 Likes
2,036 Views
10 Replies
Replies (10)
Message 2 of 11

john.uhden
Mentor
Mentor

The only problem that jumps out at me is that the result will be nil...

(setq result (vla-put-tagstring obj Exl_NewTag))

 because all vla-puts and vlax-puts return nil I'm pretty sure.

But does the attribute show the desired result?

Anyway, I prefer to use vlax-get/put... because it takes and returns plain AutoLisp lists, etc. as in

(vlax-put obj 'tagstring Exl_NewTag)

You don't have to jerk around with variants and safearrays. 

John F. Uhden

0 Likes
Message 3 of 11

Patrick.De.Neef
Advocate
Advocate

Hello John

 

Thanks for the tip, but it does not work

Result is still the same, the attribute tag name is not updates but the prompt is "erased" as you can see in the screen dumps attached to my initial message

There's also a zip file with data attached

I really don't understand what's happening, must be overlooking the obvious

 

Patrick

0 Likes
Message 4 of 11

martti.halminen
Collaborator
Collaborator

 

- The examples in the documentation also call vla-Update on the object, has that any effect?

 

- Your examples seem to show two different attributes with the same tag. That may cause problems if the program modifies the wrong one.

0 Likes
Message 5 of 11

Patrick.De.Neef
Advocate
Advocate

Hello Martti

 

replacing the duplicate attribute tags is exactly what I am trying to do 😞

adding vla-update did not help

 

P.

0 Likes
Message 6 of 11

john.uhden
Mentor
Mentor

I don't see anything that would "erase" the prompt.

Are you sure about the order of values in the Excel file?

Are you sure that the Excel data are all strings rounded to the whole number?

How about if you try confirming the change...

    (vla-put-tagstring obj Exl_NewTag)
    (princ "result = ")
    (princ (vlax-get obj 'Tagstring))
    (princ "\n")

Then maybe you need to do an update on the block definition and/or a regen.

John F. Uhden

0 Likes
Message 7 of 11

Patrick.De.Neef
Advocate
Advocate

Hello All

 

can someone explain me the following and tell me that I am not getting  ... 😋

After I ran the lisp program, eattedit always tells me that the attribute tag is not changed

However, this morning lightning struck my old brain and I tried BATTMAN

guess what ... this lovely command (and another lisp that I wrote) tells me everything is OK

so, what's wrong with eattedit ???

Please have a look at the attached word document 😀

 

Patrick

0 Likes
Message 8 of 11

kpblc2000
Advisor
Advisor

Did you ran _.attsync command ?

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.


Алексей Кулик aka kpblc | Aleksei Kulik aka kpblc Facebook | LinkedIn
autolisp.ru
Техническая поддержка программистов Autodesk в СНГ
Библиотека пользовательских lisp-функций | Custom Lisp-function library

0 Likes
Message 9 of 11

john.uhden
Mentor
Mentor

I think you're getting 😖

Are you sure an update here and there won't bring it around?

John F. Uhden

0 Likes
Message 10 of 11

Patrick.De.Neef
Advocate
Advocate

Hello John

 

Yep, was almost ... 😵😡

but kpblc2000 gave the solution 😄

(command "_.attsync" "_name" (vla-get-Name blockobj))

@kpblc2000: THANK YOU VERY MUCH !

I knew I was overlooking the obvious, Thanks for following up

Patrick

0 Likes
Message 11 of 11

john.uhden
Mentor
Mentor
YAY!! ☺

John F. Uhden

0 Likes