global variable updating but not showing on text box until I open then close


SH_Canada
 Share

Recommended Posts

I've been trying to get the layout to read a file and populate a rich text box..

 

The contents of the file(floor area) are written to when the plan file changes. This is all good.

 

In the layout, I have a macro which reads the contents of the file and puts it into a global variable. this macro is in the label of the plan object(layout box) in layout.  All is good. label updates whenever the file updates..

 

but if I put a macro which just spits out the global variable ( I cannot use the macro above because it references the file which is only available for layout boxes) in a rich text box on the layout page, it seems to only update when I open and close the text box. But  if I create the same macro to read the file and set it to a referenced object and attach a leader line text box to the layout box and put the new reference macro in it, it updates whenever the value changes.

 

The observed behavior is essentially I can see the update in the plan layout box's label or connected box, but not in the rich text box. The first two I believe are actaully showing the output of the macro as opposed to the actual global variable.

 

So it seems like when a global variable updates it does not fire an update to all things that reference it?

 

Is this expected behaviour?

 

macro I'm testing is pretty simple

 

filepath=owner.referenced_full_filename

 

logfile=File.dirname(filepath)+"/log.txt"

File.write(logfile,"123..",mode:"w")

 

filedir=File.dirname(filepath)+"/firstfloorarea.txt"

$firstfloorarealayout=File.read(filedir)

 

the textbox then calls a macro named %firstfloorarea% and all it does is:

$firstfloorarealayout

 

is there a way to call the global variable directly from a text box? Maybe that is the reason it is not updating. Maybe it is that simple, but I have not yet found it.

 

The obvious workaround is to connect a text box to the layout box (which I may do as it eliminates the global variable). But the whole thing just gets more and more clugy. After spending quite a bit of time perusing the Q&A it seems like to achieve floor area on layout is clugy whatever way you go. From drawing polylines, to plan global variables, to global variables overwriting other global variables when multiple plan or layouts are open

 

 

thanks

 

JAson

 

 

 

Link to comment
Share on other sites

7 hours ago, Joe_Carrick said:

Are you sure that File.dirname(filepath)+"/firstfloorarea.txt" exists?

 

yes, because it shows in the connect leader line box. and I write to a log file every time I read it (For testing),so i can tell it is being read successfully

 

below you can see the problem. before I took this screenshot, the floor area was 1273. Then I moved a wall in the plan and went to layout and this is what it shows. Connected leader line box is now at 1218(which matches the new area in the plan) but rich text box is still at 1273. The rich text box has only %firstfloorarea% and all that macro has in it is $firstfloorarealayout

image.thumb.png.327ffcb20ceec2082609a515f0a7700a.png

 

but if I open up the text box and then close it, it will change to match correctly:

image.thumb.png.e35e590eb0c7e1fc089db338bbc46f8d.png

Link to comment
Share on other sites

Don’t have the time or inclination to go into all the nuances in a quick post, but I think you’ll avoid a lot of problems by just placing that text box in your PLAN and just sending it to layout from there.  That way it resides in the same place that the global is being initiated.  
 

Also, just FYI, as a general rule, there needs to be a screen redraw/refresh of some sort  in order for macros to update.  This could be panning/zooming, but it also happens when you print.  Not saying this will solve your current problem.  Just something to be aware of.  

Link to comment
Share on other sites

5 hours ago, Alaskan_Son said:

Also, just FYI, as a general rule, there needs to be a screen redraw/refresh of some sort  in order for macros to update.  This could be panning/zooming

this was exactly it. Panning and zooming updates it. Thanks! good to know the behaviour. Unfortunate that his does not appear in the manual. 

 

I'm not  huge fan of global variables when you can have, and I do, have multiple files open. If the plan name was available as a method, one could create a global array, and populate the first element as the plan name, and then use this as a key to check. Unfortunately it is not.

 

I've read a lot of the other posts on getting the area with macros, polylines, global variables, but I did not see one that could do it with macros only. I have managed to get the floor areas to a text file by macro only, so I could read them back in with a macro, do the total area and populate a text box (as I am doing with a macro in layout), but do it in the plan, and then send to layout as you suggest. The advantage is I would not have to connect the goofy leader line to the layout box on my first page. It's like CA is "this close" to be able move data between the two and within the plan, ...but not quite..

Link to comment
Share on other sites

1 hour ago, DRAWZILLA said:

hitting the f5 key twice also executes macro's

thanks, also good to know.

 

Life would be simpler f we could just reference by plan and named object like you can with excel macros. ie..

myarea = plan("jason.plan").plan.floor[1].standard_area

 

then CA would look at any plan in the layout until it found jason.plan

and then get the attribute

 

and then on layout load, you could hit a refresh and it repopulates, or it would autorefresh

 

Link to comment
Share on other sites

Hi All,

 

My understanding is that the refresh issue involving global variables in text is considered "expected" behavior.  Our Development team also knows that global variables aren't anyone's favorite to work with, though.  Any time you have a use case that you're addressing using a global variable, feel free to let us know so we can look at providing a better alternative.  You can post in the Suggestions forum (https://chieftalk.chiefarchitect.com/forum/8-suggestions/), e-mail suggestions@chiefarchitect.com, or contact Technical Support (https://support.chiefarchitect.com/).

 

Thanks!

Link to comment
Share on other sites

4 hours ago, Anne_S said:

Hi All,

 

My understanding is that the refresh issue involving global variables in text is considered "expected" behavior.  Our Development team also knows that global variables aren't anyone's favorite to work with, though.  Any time you have a use case that you're addressing using a global variable, feel free to let us know so we can look at providing a better alternative.  You can post in the Suggestions forum (https://chieftalk.chiefarchitect.com/forum/8-suggestions/), e-mail suggestions@chiefarchitect.com, or contact Technical Support (https://support.chiefarchitect.com/).

 

Thanks!

thanks, I put in a suggestion to document the behaviour

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share