<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Script run with Layout Number update in Libraries &amp; objects</title>
    <link>https://community.graphisoft.com/t5/Libraries-objects/Script-run-with-Layout-Number-update/m-p/209188#M16592</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;R&gt;hi all,&lt;BR /&gt;
&lt;BR /&gt;
I'm having a mental block trying to solve a script update issue with a Titleblock object placed on a layout. &lt;BR /&gt;
&lt;BR /&gt;
What i'm doing is requesting the layout number and using this parameter to determine what style of title block should be displayed for that layout - e.g Documentation vs Presentation. The problem i'm having is the object does not seem to read a change to the Layout Number unless you open the object settings dialog. As soon as I do this i can see in the Preview that the title block has read the layout number and changed appropriately, but I have to click OK for the object to update ... which is defeating the point of this system (mass title block style changes rather than layout-by-layout).&lt;BR /&gt;
&lt;BR /&gt;
Here is the relevant script used in the Master Script - the integer parameter &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;'mi_SheetStyle'&lt;E&gt;&lt;/E&gt; is then used in a GOSUB to point to the correct style:&lt;BR /&gt;

&lt;PRE&gt;	ii=REQUEST ("HomeDB_info", "", mi_ID, mi_LayoutNumber, mi_LayoutName, mi_context)
	
        ...

	mi_SheetStyleStr = ''
	PARAMETERS mi_SheetStyleStr = STRSUB(mi_LayoutNumber, 1, 4)
	PARAMETERS mi_DwgNumLen = STRLEN(mi_DwgNum)

	! mi_SheetStyle Values
	! 1 = Documentation
	! 2 = DA
	! 3 = Sketch
	! 4 = Feasibility

	IF STRLEN(mi_DwgNum) = 9 THEN PARAMETERS mi_SheetStyle = 1
	IF STRLEN(mi_DwgNum) = 12 THEN
		IF STRSTR (mi_LayoutNumber, "DA") &amp;gt; 0 THEN PARAMETERS mi_SheetStyle = 2
		IF STRSTR (mi_LayoutNumber, "SK") &amp;gt; 0 THEN PARAMETERS mi_SheetStyle = 3
		IF STRSTR (mi_LayoutNumber, "FE") &amp;gt; 0 THEN PARAMETERS mi_SheetStyle = 4
	ENDIF
	IF STRLEN(mi_DwgNum) &amp;lt;&amp;gt; 9 AND STRLEN(mi_DwgNum) &amp;lt;&amp;gt; 12 THEN PARAMETERS mi_SheetStyle = 1
&lt;/PRE&gt;

There is probably a more elegant way of doing the last bit but it works for the moment.&lt;BR /&gt;
&lt;BR /&gt;
Can anyone identify a problem in the above which would be causing this to only be run when the object settings dialog is opened? I thought the object script should be run whenever the layout is activated, zoomed, etc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;[Edit]:&lt;/B&gt; I am using PARAMETERS commands as I need to pass these parameters to a Macro object which draws the actual title block. It seems this is the problem - the PARAMETERS are not regenerated as I used the above script directly in the Macro object without the PARAMETERS cmds and the object instantly picks up the Layout Number change. Problem is I need to use a Macro - is there any way around using PARAMETERS to store values to pass to a called Macro?&lt;BR /&gt;
&lt;BR /&gt;
cheers,&lt;BR /&gt;
&lt;BR /&gt;
owen&lt;/R&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 30 Nov 2011 13:46:28 GMT</pubDate>
    <dc:creator>owen</dc:creator>
    <dc:date>2011-11-30T13:46:28Z</dc:date>
    <item>
      <title>Script run with Layout Number update</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Script-run-with-Layout-Number-update/m-p/209188#M16592</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;R&gt;hi all,&lt;BR /&gt;
&lt;BR /&gt;
I'm having a mental block trying to solve a script update issue with a Titleblock object placed on a layout. &lt;BR /&gt;
&lt;BR /&gt;
What i'm doing is requesting the layout number and using this parameter to determine what style of title block should be displayed for that layout - e.g Documentation vs Presentation. The problem i'm having is the object does not seem to read a change to the Layout Number unless you open the object settings dialog. As soon as I do this i can see in the Preview that the title block has read the layout number and changed appropriately, but I have to click OK for the object to update ... which is defeating the point of this system (mass title block style changes rather than layout-by-layout).&lt;BR /&gt;
&lt;BR /&gt;
Here is the relevant script used in the Master Script - the integer parameter &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;'mi_SheetStyle'&lt;E&gt;&lt;/E&gt; is then used in a GOSUB to point to the correct style:&lt;BR /&gt;

&lt;PRE&gt;	ii=REQUEST ("HomeDB_info", "", mi_ID, mi_LayoutNumber, mi_LayoutName, mi_context)
	
        ...

	mi_SheetStyleStr = ''
	PARAMETERS mi_SheetStyleStr = STRSUB(mi_LayoutNumber, 1, 4)
	PARAMETERS mi_DwgNumLen = STRLEN(mi_DwgNum)

	! mi_SheetStyle Values
	! 1 = Documentation
	! 2 = DA
	! 3 = Sketch
	! 4 = Feasibility

	IF STRLEN(mi_DwgNum) = 9 THEN PARAMETERS mi_SheetStyle = 1
	IF STRLEN(mi_DwgNum) = 12 THEN
		IF STRSTR (mi_LayoutNumber, "DA") &amp;gt; 0 THEN PARAMETERS mi_SheetStyle = 2
		IF STRSTR (mi_LayoutNumber, "SK") &amp;gt; 0 THEN PARAMETERS mi_SheetStyle = 3
		IF STRSTR (mi_LayoutNumber, "FE") &amp;gt; 0 THEN PARAMETERS mi_SheetStyle = 4
	ENDIF
	IF STRLEN(mi_DwgNum) &amp;lt;&amp;gt; 9 AND STRLEN(mi_DwgNum) &amp;lt;&amp;gt; 12 THEN PARAMETERS mi_SheetStyle = 1
&lt;/PRE&gt;

There is probably a more elegant way of doing the last bit but it works for the moment.&lt;BR /&gt;
&lt;BR /&gt;
Can anyone identify a problem in the above which would be causing this to only be run when the object settings dialog is opened? I thought the object script should be run whenever the layout is activated, zoomed, etc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;[Edit]:&lt;/B&gt; I am using PARAMETERS commands as I need to pass these parameters to a Macro object which draws the actual title block. It seems this is the problem - the PARAMETERS are not regenerated as I used the above script directly in the Macro object without the PARAMETERS cmds and the object instantly picks up the Layout Number change. Problem is I need to use a Macro - is there any way around using PARAMETERS to store values to pass to a called Macro?&lt;BR /&gt;
&lt;BR /&gt;
cheers,&lt;BR /&gt;
&lt;BR /&gt;
owen&lt;/R&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 30 Nov 2011 13:46:28 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Script-run-with-Layout-Number-update/m-p/209188#M16592</guid>
      <dc:creator>owen</dc:creator>
      <dc:date>2011-11-30T13:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Script run with Layout Number update</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Script-run-with-Layout-Number-update/m-p/209189#M16593</link>
      <description>Please try to check, if it helps, when you not only set the parameters by the PARAMETERS command, but set the variables as well.&lt;BR /&gt;
It is a normal behaviour, that parameters only change (running of the Parameters Script) when an object is run in the settings dialog and you click ok.&lt;BR /&gt;
Maybe the object reads the changes, but does not change the parameters, but maybe not. If it does, it should help, when you set the variables too.&lt;BR /&gt;
Example:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;IF STRLEN(mi_DwgNum) = 9 THEN  
mi_SheetStyle = 1 
PARAMETERS mi_SheetStyle = mi_SheetStyle 
ENDIF
&lt;/PRE&gt;

I think, you do not need to set parameters to pass them to a macro; in my opinion you can pass variables to the macro as well.</description>
      <pubDate>Wed, 30 Nov 2011 21:43:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Script-run-with-Layout-Number-update/m-p/209189#M16593</guid>
      <dc:creator>Jochen Suehlo</dc:creator>
      <dc:date>2011-11-30T21:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script run with Layout Number update</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Script-run-with-Layout-Number-update/m-p/209190#M16594</link>
      <description>Joachim,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help ... that worked, and now its not so late your explanation makes total sense to me.&lt;BR /&gt;
&lt;BR /&gt;
I did try passing variables direct to the macro but could not get it to work:&lt;BR /&gt;
&lt;BR /&gt;
1. If the variable was generated in the caller and only used in the macro then it was uninitialized and the called object did not display.&lt;BR /&gt;
&lt;BR /&gt;
2. If i initialized the variable in the Macro (e.g mi_SheetStyle = 1) then it isn't changed by the caller (or it is but then overwritten by this default value (1) which is read after the variable value passed from the Caller if i understand my script sequence correctly)&lt;BR /&gt;
&lt;BR /&gt;
3. If i initialized the variable in the Macro by adding as a parameter with a default value then the default parameter value isn't changed by the variable in the caller (this requires a PARAMETERS statement)&lt;BR /&gt;
&lt;BR /&gt;
.. Point 3 led me to setting as a parameter in the caller as well, then it works.&lt;BR /&gt;
&lt;BR /&gt;
But there is a good chance i am just not doing it right ... what is the correct way to pass a variable from Caller to Macro?&lt;BR /&gt;
&lt;BR /&gt;
cheers,&lt;BR /&gt;
&lt;BR /&gt;
owen</description>
      <pubDate>Wed, 30 Nov 2011 23:36:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Script-run-with-Layout-Number-update/m-p/209190#M16594</guid>
      <dc:creator>owen</dc:creator>
      <dc:date>2011-11-30T23:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Script run with Layout Number update</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Script-run-with-Layout-Number-update/m-p/209191#M16595</link>
      <description>Owen, I don't know if I understand you right, but try this:&lt;BR /&gt;
&lt;BR /&gt;
1. a caller object must not have to pass parameters;&lt;BR /&gt;
example Master-Script:&lt;BR /&gt;
CALL "testwuerfel" PARAMETERS A=1, B=2, zzyzx = 3&lt;BR /&gt;
the passed values are fixed variables.&lt;BR /&gt;
This PARAMETERS statement does not work the same as the one, that sets parameters within an object. But I don't know if you get the same problem then with the parameters that only change when you go to the settings dialog and click ok; i haven't checked this.&lt;BR /&gt;
&lt;BR /&gt;
2. the called object must have the passed values as parameters, which means that the passed values have to be declared as parameters in the parameter section of the GDL editor.&lt;BR /&gt;
example 3D in macro:&lt;BR /&gt;
BLOCK a,b,zzyzx&lt;BR /&gt;
2D:&lt;BR /&gt;
PROJECT2 3,270,2&lt;BR /&gt;
TEXT2 0,0,STR(A,4,2)+","+STR(b,4,2)+","+STR(zzyzx,4,2)&lt;BR /&gt;
&lt;BR /&gt;
the 2d-plan of the caller shows the correct dimensions (text) of the passed values 1,2,3.</description>
      <pubDate>Thu, 01 Dec 2011 17:33:51 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Script-run-with-Layout-Number-update/m-p/209191#M16595</guid>
      <dc:creator>Jochen Suehlo</dc:creator>
      <dc:date>2011-12-01T17:33:51Z</dc:date>
    </item>
  </channel>
</rss>

