Lisp & DBX

Lisp & DBX

Anonymous
Not applicable
809 Views
3 Replies
Message 1 of 4

Lisp & DBX

Anonymous
Not applicable

Hello
I use a translator, so sorry for my English.
I have such a problem here.
I'm in the file 'plan.dwg'.
Use the

(setq MyHandle "223") ; Handle element which wishes to change, which is in the file 'cross.dwg'
(setq file "C:\\temp\\cross.dwg")
(setq dbx (vla-getInterfaceObject(vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." (substr (getvar "ACADVER") 1 2)))) (vla-open dbx file)

 

get to the file 'cross.dwg', in which there is an element (an element of type 'TEXT' in modelspace) which I seek by using the

 

(vlax-for %1 (vla-get-modelspace dbx)
  (if (= (vla-get-Handle %1) MyHandle)
    (progn
(setq txt (vla-get-TextString %1)) (acet-ui-message (strcat "I have \n\"" txt "\"") "attempt" 65) ) ) ) (vlax-release-object dbx)


What do I do now to change the content (TextString) this item?

 

Below the code.

 

(defun c:polki ( / MyHandle file dbx %1 txt)
  (setq MyHandle "223"); Handle element which wishes to change, which is in the file 'cross.dwg'
  (setq file "C:\\temp\\cross.dwg")
  (setq dbx (vla-getInterfaceObject(vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." (substr (getvar "ACADVER") 1 2))))
  (vla-open dbx file)
  (vlax-for %1 (vla-get-modelspace dbx)
    (if (= (vla-get-Handle %1) MyHandle)
      (progn
	(setq txt (vla-get-TextString %1))
	(acet-ui-message (strcat "I have\n\"" txt "\"") "attempt" 65)
	;Here you want to change the content of this item -> %1
	; (vla-put-TextString -> What's next?
	)
      )
    )
  (vlax-release-object dbx)
  )

 

Jerzy

810 Views
3 Replies
Replies (3)
Message 2 of 4

hmsilva
Mentor
Mentor

Hello Jerzy and welcome to the Autodesk Community!

 

Try

 

(vla-put-TextString %1 "the new text string")
(vla-saveas dbx file)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you very much.
It worked.

0 Likes
Message 4 of 4

hmsilva
Mentor
Mentor

@domkupie3 wrote:

Thank you very much.
It worked.


You're welcome, Jerzy
Glad I could help

Henrique

EESignature

0 Likes