Jump to content
Developer Wiki and Function Reference Links ×

objects that update each other


Recommended Posts

I have made a pio That has a few parameters I would like to have shared between all instances of the object in a single file across layers.  Can someone point me to a code example of how to accomplish this? I found an article about naming the objects with uuid but cant seem to relocate it. 

Link to comment

You write a Procedure which seeks out all instances of the plugin and assign it to a button in the OIP. The tricky part I suspect might be whether or not the values you just changed in the plugin instance have been transferred to the attached resource so that you can capture them to copy to all the other instances. The script compiler usually doesn't update the resources until the script finishes. Would pressing this "update" button cause the plugin instance's script to run a second time if a reset object was issued in the script?

Sorry I don't think I have any relevant examples.

 

<edit: I suppose you could use the Procedure in a tool and simply click on the plugin instance that you wish to transfer the values from to its other brethren. Just place script in the right mouse button menu if it is a frequent use item. >

Edited by LarryO
Link to comment

Are these parameters that effect how the object draws? Or are they just values that need to be the same for data extraction purposes, say something like weight?

 

If they effect how the object draws, you are probably going to want a separate command/script to synchronize the values or else you risk a bad recursion issue where you change the parameter and reset the PIO and then when that PIO resets, it resets all of the others, that then reset all of the others, etc.

 

One possibility would be to add an additional hidden parameter that is set for the other instances at the same time as you change their parameters. The code for the PIO would then look at that field and if it was set, it would unset the field and NOT reset the other instances.  Or the inverse of this, check and see if you changed the other instances and if so ONLY THEN reset the other instances.

 

Something like:

 

IF DID_I_Change_Other_Instances then
ForEachObject(ResetObject, ((PON='MyPIOName')));

 

And yes, you can use a standard Procedure with ForEachObject, it does not have to be a custom Procedure defined in your script.

 

If you want to only reset a subset of the PIO, you could class them, or add another parameter to use in the criteria rather than trying to track UUIDs.

 

HTH.  Ask again if you need more help.

Link to comment

I have been experimenting with ForEachObject and see how that will let me cycle through resetting all my pio's, What I am missing is getting one pio to read the state of a boolean in another pio, and how to get a parameter (i.e rMargin) that is entered in the 1st pio to end up in the 2nd pio on its reset.  I really appreciate all the help guys.  

Link to comment

It is probably easier to PUSH the data from your Master object to the other objects than to try and have each individual object PULL the data from the master.

 

If you want to PULL, then you need some way to identify which object is the Master. Best option is probably another parameter that will specify the Master object. You can then use a criteria that matches that parameter to get a handle to the Master object and then read the values you need and store them into the proper parameters of each object.

 

If you want to PUSH then that is what I described above. Again I would suggest some kind of parameter to specify which object is the Master unless you always want EVERY pio to have the same parameter values.  When the Master object has a parameter that you want PUSHED to the other objects you would then use something like the ForEachObject with a Criteria of PON='MyPIOName' The called procedure would then use SetRField to set the values to each object in turn and  do a ResetObject.

 

If you want a change in ANY pio to change the others, then it would be like the PUSH option, but you will need to make sure that you only run the part of the script that effects the other objects if you manually make a change to that instance and then only change the other objects if you have.

 

HTH

Link to comment

Pat, Thanks so much 

 

I am having trouble interacting with the record, I made a simple object with some parameters so I can play with it, but cant seem to figure out the format. this code tells me that there are 6 records, I cant seem to get record or field names out to understand the structure where should I look for more explanation on the record format and how to interact with it?

 

 

PROCEDURE pioudate;

VAR 
    rMargin, rLayerScale, rWidth, rHeight : real;
    p1, p2 :point;
    iNumInst : longint;
    H1, H2, H3 : handle;
    F1,F3,F4,F5,F6,F7,F8,F9,F10:STRING;
    F2, NumOfRec, NumOfFields : integer;
    
            (*
            procedure editParam(h:handle c:longint);
                Begin
                h:=GetObjet('interconected pio Copy');
                c:=Count(N = 'interconected pio Copy');
                SetRField(h,'PiNumInst',
             *)    
    
    
    
Begin
rWidth:=PrWidth;
rHeight:=PrHeight;    
rLayerScale:=GetLScale(ActLayer);    
iNumInst:=PiNumInst;
rMargin:=PrMargin*rLayerScale;

    Rect(p1.x,p1.y,p2.x,p2.y);
    MoveTo(p2.x-(1.6*rLayerScale)-rMargin,p2.y+rMargin);
    Rect(rWidth*rLayerScale, #0, rHeight*rLayerScale, #90);
    
iNumInst:=Count(N = 'interconected pio Copy');

H1:=LNewObj; 
H2:=GetRecord(H1,1);
H3:=GetParametricRecord(H1);


NumOfFields:=NumFields(H3);
NumOfRec:=NumRecords(H3);

F1:=GetFldName(H3, 1);
F2:=GetFldType(H3, 1);
F3:=GetRField(H3, 'Margin','Margin');

{F4:=GetFldName(H3, 4);}

(*
F5:=GetFldName(H2, 5);
F6:=GetFldName(H2, 6);
F7:=GetFldName(H2, 7);
F8:=GetFldName(H2, 8);
F9:=GetFldName(H2, 9);
F10:=GetFldName(H2, 10);
*)


message(CONCAT(' * ',f1,' * ',NumOfFields,' * ',NumOfRec,' * ',F2,F3,F4,F5,F6,F7,F8,F10));    
    

End;
RUN(pioudate);

Link to comment

H3 is already a handle to a record, so getting the number of records will not work. I don't think you can attach a record to a record.

 

Also, I believe the H2 and H3 should be the same. I THINK (I would have to check to be sure) that the Parameter Record is the first record attached to the object.

 

Can you please post the .vso file for the plugin so I don't have to try and recreate the parameters?

Link to comment

ok, so using GetCustomObjectInfo I have been able to capture what I needed, 

 

InfoSuccesful:= GetCustomObjectInfo(ojectName, objectHand, recordHand, wallHand);
H1:=objectHand;
H2:=recordHand;
H3:=wallHand;

sRecordName:=GetName(H2);
NumOfFields:=NumFields(H2);
NumOfRec:=NumRecords(H1);
F1:=GetFldName(H2, 3);
F2:=GetFldType(H2, 3);
F3:=GetRField(H1,sRecordName,f1);


message(CONCAT(NumOfFields,'*',ojectName, '*',sRecordName,'*',f1,'*',F3));

 

I was passing the wrong handle to GetRField.  thanks for your willingness to help,  I am back onto figuring out how to use your "push" values example.    

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...