Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vl Function for updating Fields or Object?

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
1306 Views, 7 Replies

Vl Function for updating Fields or Object?

Im writing a reactor that when a user selects a Dynamic block the field
contained inside the Dynamic block will update. Well I can get the field to
update using the below code.

(vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)

But unfortunately in a large drawing these full regens take a long time to
update all the information in the drawing. Especially when we have a lot of
fields to update constantly.

So, is there a Vl function that will update ONLY the object that I select.
Similar to what UPDATEFIELD does, where you can select an object and update
only that field.

Thanks for any help!!

--
Mark Douglas
AutoCAD, Lisp, DWF & Dynamic Block Blog
http://mdouglas.blogs.com/in_the_dynamic_interface/
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

So, is there a Vl function that will update ONLY the object that I select.
Similar to what UPDATEFIELD does, where you can select an object and update
only that field.

--------------------------

Do not know if it is, but you can put the desired mtext's into dictionaries
and grab them from there.

In the cases of being part of tables, then place the table instead of the
field as part of the dictionary.

Then, just call your dictionary and use the command updatefield.

IE:
(vlax-ldata-put "selection1" "fields" (list ename1 ename2))
(setq lst1 (vlax-ldata-get "selection1" "fields"))
(setq ss (ssadd))
(foreach e lst1 (ssadd e ss))
(command "_.updatefield" ss "")
Message 3 of 8
mkweaver01
in reply to: Anonymous

Won't the update method of the mtext/attribute/text containing your field work? Or maybe the update method for the insert object?

Or do I not understand the problem (likely).

Mike Weaver
Message 4 of 8
Anonymous
in reply to: Anonymous

Hi Mike,

This was another approach I was trying but got stuck on this as well as I
think I was coding it wrong.
Basically I think just updating the object, or regenning just the object
should do the trick.

Thanks for any help!!

Mark

wrote in message news:5382263@discussion.autodesk.com...
Won't the update method of the mtext/attribute/text containing your field
work? Or maybe the update method for the insert object?

Or do I not understand the problem (likely).

Mike Weaver
Message 5 of 8
Anonymous
in reply to: Anonymous

>Won't the update method of the mtext/attribute/text containing your field
>work? Or maybe the update method for the >insert object?

Calling: (vla-update obj_field) - won't work. (if that was the method you
reffering)
Message 6 of 8
Anonymous
in reply to: Anonymous

Here is the code. This works like I said, but just takes too long on large
drawings.

(defun DoDynBlkReactor (reactor info / )

(setq ent (ssname (cadr (ssgetfirst)) 0))
(if ent
(progn
(setq entlst (entget ent))
(if (= "INSERT" (cdr (assoc 0 entlst)))
(progn
(if (or (= (car info) "GRIP_POPUP") (= (car info)
"GRIP_STRETCH"))

(vla-update)
(vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object))
acActiveViewport)

);_ if
);_ progn
);_ if
);_ progn
);_ if

(princ)
)

--
Mark Douglas
AutoCAD, Lisp, DWF & Dynamic Block Blog
http://mdouglas.blogs.com/in_the_dynamic_interface/


"CPP" wrote in message
news:5383109@discussion.autodesk.com...
>Won't the update method of the mtext/attribute/text containing your field
>work? Or maybe the update method for the >insert object?

Calling: (vla-update obj_field) - won't work. (if that was the method you
reffering)
Message 7 of 8
Anonymous
in reply to: Anonymous

> (vla-update)
> (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object))
> acActiveViewport)

Yes;

I recall doing something similar, the first time they introduce the field
objects, and end up giving up.

Lately, I simple have a little simple lisp routine in my acad.mnl file like
this:

================================

(defun C:UPDFIELDS (/ ss1 ss)
(if (setq ss1 (ssget "X" '((0 . "MTEXT"))))
(progn
(setq ss (ssadd))
(mapcar
'(lambda (ename / ent)
(if (and (setq ent (cdr (assoc 360 (entget ename))))
(dictsearch ent "ACAD_FIELD"))
(ssadd ename ss)))
(vl-remove-if
(function listp)
(mapcar (function cadr) (ssnamex ss1))))
(if (and ss (/= (sslength ss) 0))
(progn
(acad-push-dbmod)
(command "_.updatefield" ss "")
(acad-pop-dbmod)))))
(princ))
(C:UPDFIELDS)

================================

But, no reactors were used 🙂

Try the approach I mentioned about dictionaries, it might lead you to a
possible solution, could be.
Message 8 of 8
Trev_Smith
in reply to: Anonymous

An old thread I just stumbled on whilst searching for something.

Here are a couple of simple ways.

 

vanilla autolisp will cover this with a simple command line method >

(setq #Obj1(entsel "\nSelect Object:"))

(command "_updatefield" #Obj1 "")

or combine if you need the variable later

(command "_updatefield" (setq #Obj1(entsel "\nSelect Object:")) "")

or just the one line

(command "_updatefield" (entsel "\nSelect Object:") "")

 

in VisualLisp you can use vla-sendcommand >

Although this needs to be written as you'd type it directly at the command prompt and a bit harder to ensure you get the string with a variable.

 

(vl-load-com)  ; load visual lisp programming base.

(setq #thisdwg (vla-get-activedocument (vlax-get-acad-object)))

(vla-SendCommand #thisdwg "_updatefield ")<make sure there is one space after the _updatefield as it will emulate the enter key to accept the command at the command line

 

You can expand on the send command to ask a more appropriate question etc. but will need to pass a variable to the command line >

(setq #Obj1(entsel "\nSelect object to update fields:"))

(setq #thisdwg (vla-get-activedocument (vlax-get-acad-object)))

(vla-SendCommand #thisdwg "_.updatefield !#Obj1  ")  < two spaces after !@Obj1 for the line to be run through at the command prompt.

the " ! " prior to the variable is the way you'd see the variable value if typing at the command prompt eg: !variablename

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost