Jump to content

DeSignature

Member
  • Posts

    44
  • Joined

  • Last visited

Posts posted by DeSignature

  1. Following your remarks, I have deleted the LinkText() calls,

    I tried to include the GetObject function in about every part of the script,

    I tried to include the DefineCustomObj function in about every part of the script - every part but the correct one, I guess - using the 3 possible preference settings,

    I did not delete or replace the GetRField function since I do use the SetRField function in the script.

    but still, in every case the texts do not get displayed at insertion of the PIO.

     

    As far as I can understand, I have to try to create the records before anything else happens in the script, so I guess I I'm creating the records at the wrong time in the script.

    As I have mentioned above, the DefineCustomObj function did not help out on this one, where should I call this function?

  2. It's just that GetObject(plug-in_name) contained 'plug-in_name' and not 'plug-in_handle', but I really do agree it would have been much wiser to check the function reference before putting out my opinion and I will keep your advise in mind.

    Hoping I didn't offend anybody in any way,

    Dimitri.

  3. Well I'll definitely will have to give that a try, but something tells me that this function will look for inserted PIO's and not for (hidden) PIO records ...

    Anyway, I have simplified the actual code and tested the result, the result is the same, the variable strings are not being displayed at the moment of insertion,

    they get displayed when the 'Edit Subgeometry' dialog gets confirmed or when the PIO is being reinserted.

    Really looking forward to your findings, just hoping it won't be something too obvious ...

    Dimitri.

    PROCEDURE Simple;
    VAR
    	PIO_N			: STRING;
    	PIO_H, PIO_R, PIO_W	: HANDLE;
    	EventId, EventResult	: LONGINT;
    	DialogId, DialogResult	: LONGINT;
    	Result			: BOOLEAN;
    	Txt			: STRING;
    
    	PROCEDURE Geometry;
    		PROCEDURE Define_Size;
    		BEGIN
    		END;
    
    		PROCEDURE Draw_Geometry;
    		BEGIN;
    			RectangleN (-30, -15, 1, 0, 60, 30);
    		END;
    
    		PROCEDURE Insert_Subgeometry;
    			PROCEDURE Draw_Subgeometry;
    			BEGIN
    				MoveTo (-30, 10);
    				LineTo (60, #0);
    				MoveTo (0, -15);
    				LineTo (30, #90);
    			END;
    
    			PROCEDURE Insert_Text_Items;
    				PROCEDURE Insert_Text_Items_A (x, y: REAL; T: STRING);
    				BEGIN
    					TextSize (8);
    					MoveTo (x, y);
    					CreateText (T);
    				END;
    
    				PROCEDURE Insert_Text_Items_B (x, y, StrS: REAL; T: STRING);
    				BEGIN
    					TextSize (StrS);
    					MoveTo (x, y);
    					CreateText (T);
    				END;
    
    			BEGIN
    				Insert_Text_Items_A (-15, 12.5, 'Text A:');
    				Insert_Text_Items_A (15, 12.5, 'Text B:');
    				{ ... }
    
    				Insert_Text_Items_B (-15, 0, 12, GetRField (PIO_H, PIO_N, 'RecordField A'));
    				LinkText (LNewObj, PIO_N, GetRField (PIO_H, PIO_N, 'RecordField A'));
    				Insert_Text_Items_B (15, 0, 12, GetRField (PIO_H, PIO_N, 'RecordField B'));
    				LinkText (LNewObj, PIO_N, GetRField (PIO_H, PIO_N, 'RecordField B'));
    				{ ... }
    			END;
    		BEGIN
    			Draw_Subgeometry;
    			Insert_Text_Items;
    		END;
    	BEGIN
    		Define_Size;
    		Draw_Geometry;
    		Insert_Subgeometry;
    	END;
    
    	PROCEDURE EditSubgeometry;
    		PROCEDURE Records;
    		BEGIN
    			NewField (PIO_N, 'RecordField A', 'TEXT A', 4, 1);
    			NewField (PIO_N, 'RecordField B', 'TEXT B', 4, 1);
    			{ ... }
    		END;
    
    		PROCEDURE Apply2All (ObjH: HANDLE);
    		BEGIN
    			GetItemText (DialogID, 161, Txt);
    			SetRField (ObjH, PIO_N, 'RecordField A', Txt);
    			{ ... }
    			ResetObject (ObjH);
    		END;
    
    		PROCEDURE DialogLayout;
    		BEGIN
    			DialogId := CreateLayout ('Dialog A', FALSE, 'OK', 'Cancel');
    
    			CreateGroupBox			(DialogId, 100, 'Tab A', FALSE);
    			CreateRightStaticText	(DialogId, 110, 'Text A:', 20);
    			CreateEditText			(DialogId, 111, 'TEXT A', 41);
    			{ ... }
    			CreateCheckBox			(DialogId, 120, 'Apply To All');
    				SetFirstGroupItem	(DialogId, 100, 110);
    				SetRightItem		(DialogId, 110, 111, 0, 0);
    				SetBelowItem		(DialogId, 110, 120, 0, 0);
    				{ ... }
    
    			CreateGroupBox			(DialogId, 200, 'Tab B', FALSE);
    			CreateRightStaticText	(DialogId, 210, 'Text B:', 20);
    			CreateEditText			(DialogId, 211, 'Text B', 41);
    			{ ... }
    				SetFirstGroupItem	(DialogId, 200, 210);
    				SetRightItem		(DialogId, 210, 211, 0, 0);
    				{ ... }
    
    			CreateTabControl		(DialogId, 10);
    			SetFirstLayoutItem		(DialogId, 10);
    			CreateTabPane			(DialogId, 10, 100);
    			CreateTabPane			(DialogId, 10, 200);
    		END;
    
    		PROCEDURE DialogEvents (VAR Item, Data: LONGINT);			
    			PROCEDURE DialogSettings;
    			BEGIN
    				SetItemText (DialogID, 111, GetRField (PIO_H, PIO_N, 'RecordField A'));
    				{ ... }
    
    				SetItemText (DialogID, 211, GetRField (PIO_H, PIO_N, 'RecordField B'));
    				{ ... }
    			END;
    
    			PROCEDURE ConfirmDialog;
    			BEGIN
    				GetItemText (DialogId, 111, Txt); SetRField (PIO_H, PIO_N, 'RecordField A', Txt);
    				{ ... }
    				
    				GetItemText (DialogId, 211, Txt); SetRField (PIO_H, PIO_N, 'RecordField B', Txt);
    				{ ... }
    				
    				GetBooleanItem (DialogID, 120, Result);
    				IF Result = TRUE THEN ForEachObject (Apply2All, PON = PIO_N);
    
    				ResetObject (PIO_H);
    			END;
    			
    			PROCEDURE CancelDialog;
    			BEGIN
    			END;
    		BEGIN
    			IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    			CASE Item OF
    				SetupDialogC	:	DialogSettings;
    				1		:	ConfirmDialog;
    				2		:	CancelDialog;
    			END;
    		END;
    	BEGIN
    		Records;
    		DialogLayout;
    		IF VerifyLayout (DialogID) THEN DialogResult := RunLayoutDialog (DialogID, DialogEvents);
    	END;
    
    	PROCEDURE Button_B;
    	BEGIN
    	END;
    
    	PROCEDURE Button_C;
    	BEGIN
    	END;
    
    	PROCEDURE Button_D;
    	BEGIN
    	END;
    
    	PROCEDURE AutoEdit;
    	VAR
    		AutoTxt		: STRING;
    	BEGIN
    		AutoTxt		:= GetFName;
    
    		IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    		BEGIN
    			SetRField (PIO_H, PIO_N, 'RecordField A', AutoTxt);
    			{ ... }
    		END;
    		ResetObject (PIO_H);
    	END;
    BEGIN
    	vsoGetEventInfo (EventId, EventResult);
    	CASE EventId OF
    		03:
    		IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    		BEGIN
    			PushAttrs;
    				Geometry;
    			PopAttrs;
    		END;	
    
    		05:
    		BEGIN
    			Result	:= SetObjPropVS (08, TRUE);
    			Result	:= vsoInsertAllParams;
    			Result	:= vsoAppendWidget (12, 100, 'Edit Subgeometry', 0);
    			Result	:= vsoAppendWidget (12, 200, 'Button B', 0);
    			Result	:= vsoAppendWidget (12, 300, 'Button C', 0);
    			Result	:= vsoAppendWidget (12, 400, 'Button D', 0);
    			Result	:= vsoAppendWidget (12, 500, 'Auto Edit', 0);
    		END;
    
    		35:
    		IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN CASE EventResult OF
    			100:	EditSubgeometry;
    			200:	Button_B;
    			300:	Button_C;
    			400:	Button_D;
    			500:	AutoEdit;
    		END;
    	END;
    END;
    RUN (Simple);

     

  4. The function Count (R IN [PIO_N]) helped me out here, but I could not find a the criteria to see if a record already exists in a drawing.

    Since the function above checks if there exists an object with the referenced record attached to it in the drawing, it still doesn't check if a certain record exists in the drawing.

    If I insert the PIO in a drawing for the first time the Count will return 0, once I've inserted 1 PIO, the count will return 1, but if I delete the PIO the count would return 0 again - which would be correct, but the PIO did create a record and if I delete the PIO, the record would still exist in the drawing.

     

    EDIT:

    This function only helped me out to display the text objects at the insertion of the PIO, since the created texts were constant strings ('Some Text'), they couldn't be edited anymore, so ...: back to the drawing board.

  5. Is there a function or a procedure that can check whether or not a record already exists in a drawing?

     

    Apparently, if I replace the variable strings ( GetRField (PIO_H, PIO_R, StrVar) ) in the linked text items by constant strings ( 'Some Text' ), then the text items get displayed at the first insertion of the PIO.

    So, I guess I could write a code that checks if the record is already present in the current drawing,

    if not then the text items should use constant strings, if so then the text items should use variable strings.

  6. The PIO is not being placed via a script, I just click a button in a tool palette and place the corresponding (custom) object somewhere on a sheet layer.

    For now, I'll check out the DefineCustomObj function.

    Thanks.

     

  7. How come, if I call my PIO a first time in a drawing that all PIO record fields - since all the respective text items that are created in that PIO are blanc - appear to be empty?

    If I delete that PIO en recall the same PIO, all the text items are displayed as I intended them to be displayed.

     

    When I insert the PIO in a new drawing, there is no PIO record in the new drawing, I guess when I reinsert the PIO, the PIO can get it's values from the record created by the first call.

    Is there a standard procedure to avoid this behavior?

  8. I realized I should start a new topic since the problem in the previous topic Select PIO's on Sheet Layers has been solved, so:

     

    Quote

    Well, here's my cry.

    As suggested I'm trying out the ForEachObjectInLayer procedure.

    The function in the procedure is able to select every PIO on every layer (no matter the layer type, for now), it is able to edit the text in the PIO on the current layer, but it doesn't edit the text in the PIO's on the other layers.

     

    As I (kind of) mentioned before:

    A widget button in the PIO creates a custom dialog box, there's an EditText-field in that dialog box that edits a record field and the record field edits the text that is created in the PIO.

    Since the function can select the PIO on all layers, how come it doesn't edit the text on ALL layers?

    Could it be because of the widget button or the custom dialog?

    I use a checkbox in the dialog box to edit the text (IF BooleanItem returns TRUE then ForEachObjectInLayer (FUNCTION, 0, 2, 1)),

    but since I only push the widget button and since I only check the checkbox in the PIO on the current layer, the widget buttons and the checkboxes in the dialog boxes in the PIO's on the other layers don't get pushed and don't checked.
    I've tried the SetBooleanItem (DialogID, ..., TRUE) in the function, but that doesn't suffice to do the trick.

     

  9. Thanks Julian,

    This works perfect to select the PIO - as I asked in my post - and I hoped this answer would solve my problem.

     

    Actually I'm trying to use something like the title block feature "apply to all title blocks" (loosely translated).

    In my PIO I've managed to create a text that is linked to a RField, a custom dialog sets the RField and edits the text on a sheet layer.

    The suggested criteria can select the PIO, but it doesn't help to edit the text on all the sheet layers, I guess I will have to revise the procedure I've used in ForEachObject(Procedure, Criteria).

     

    Are there any other criteria that refer to sheet layers, I know GetObjectVariableInt (ObjHandle, 154) should return '2' for sheet layers, but this knowledge doesn't seem to help out here, I can't use it to set the criteria.

     

    Thanks again,

    Dimitri.

     

  10. We usualy get by with about 6 relevant hatches, so it seems doable to me, especially if we would restrict the number of hatches in the dialog to about twelve items [1..12].

    Wouldn't be bad for the drawing hygiene as well...

     

    What would be the easiest way to differentiate between the different hatches.

    I guess I would have to script something like the code mentioned above, but I noticed it is will not be as easy as that.

     

    Any basic suggestions about how to aproach this dialog? or how to approach a dialog with n-number of items? 

  11. Hi,

     

    I'm trying to display a legend, but I would like to be able to select the specific hatches to be displayed.

    Since I don't know how many hatches are used in a drawing, would it be possible to build a dialog according to the - schematic - code below? 

    HatchId := BuildResourceList (66, 14, 'Hulpbronnen - Lijnarceringen', HatchNum);
    
          FOR n := 1 TO HatchNum DO
              CreateCheckBox (DialogId, Item(n), Index2Name(Item(n)));
    
              SetFirstLayoutItem (DialogId, Item(n));
              SetBelowItem (DialogId, Item(n), Item(n) + 1, 0, 0);

     

     

  12. ... still trying to store data in record-fields ...

    The data actually passes to record fields but are being reset when re-entering the dialogue via the "Button 1"-dialogue. Am I missing a loop somewhere?

    PROCEDURE Point_Object;
    CONST
    Confirm					= 01;
    Cancel					= 02;
    Reset_PIO				= 03;
    k_Icon					= 05;
    PIO_Controls_Palette	= 08;
    k_Palette_Button		= 35;
    VAR
    PIO_N				: STRING;
    PIO_H, PIO_R, PIO_W	: HANDLE;
    Event, Result		: LONGINT;
    Bool				: BOOLEAN;
    Dial_ID, Dial_Res	: INTEGER;
    D_X, D_Y, D_Z		: REAL;
    
    PROCEDURE Result_A;
    BEGIN
    	IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    	BEGIN
    		Rect (0, 0, pD_A, pD_B);
    		Message (GetRField (PIO_H, 'Rec_N', 'Data X'));
    	END;
    END;
    
    PROCEDURE Result_B;
    BEGIN
    END;
    
    PROCEDURE Records;
    BEGIN
    	NewField ('Rec_N', 'Data X', Concat (D_X), 9, 0);
    	NewField ('Rec_N', 'Data Y', Concat (D_Y), 9, 0);
    	NewField ('Rec_N', 'Data Z', Concat (D_Z), 9, 0);
    END;
    
    PROCEDURE Dialogue_A;
    	PROCEDURE Layout_Dialogue_A;
    	BEGIN
    		Dial_ID		:= CreateResizableLayout ('Dialogue A', TRUE, 'Confirm', 'Cancel', TRUE, TRUE);
    			CreateCheckBox		(Dial_ID, 100, 'Do Something');
    			CreateStaticText	(Dial_ID, 110, 'Data X:', 20);
    			CreateEditReal		(Dial_ID, 111, 3, D_X, 20);
    			CreateStaticText	(Dial_ID, 120, 'Data Y:', 20);
    			CreateEditReal		(Dial_ID, 121, 3, D_Y, 20);
    			CreateStaticText	(Dial_ID, 130, 'Data Z:', 20);
    			CreateEditReal		(Dial_ID, 131, 3, D_Z, 20);
    
    			SetFirstLayoutItem	(Dial_ID, 100);
    			SetBelowItem		(Dial_ID, 100, 110, 0, 0);
    			SetRightItem		(Dial_ID, 110, 111, 0, 0);
    			SetBelowItem		(Dial_ID, 110, 120, 0, 0);
    			SetRightItem		(Dial_ID, 120, 121, 0, 0);
    			SetBelowItem		(Dial_ID, 120, 130, 0, 0);
    			SetRightItem		(Dial_ID, 130, 131, 0, 0);
    	END;
    
    	PROCEDURE Dialogue_A_Handler (VAR Item, Data: LONGINT);
    		PROCEDURE Dialogue_A_Settings;
    		BEGIN
    			Bool	:= GetEditReal (Dial_ID, 111, 3, D_X);
    			Bool	:= GetEditReal (Dial_ID, 121, 3, D_Y);
    			Bool	:= GetEditReal (Dial_ID, 131, 3, D_Z);
    		END;
    
    		PROCEDURE Confirm_Handler;
    		BEGIN
    			IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    			BEGIN
    				Bool	:= GetEditReal (Dial_ID, 111, 3, D_X);
    				Bool	:= GetEditReal (Dial_ID, 121, 3, D_Y);
    				Bool	:= GetEditReal (Dial_ID, 131, 3, D_Z);
    
    				AlrtDialog (Concat (D_X));
    
    				SetRField (PIO_H, 'Rec_N', 'Data X'	, Concat (D_X));
    				SetRField (PIO_H, 'Rec_N', 'Data Y'	, Concat (D_Y));
    				SetRField (PIO_H, 'Rec_N', 'Data Z'	, Concat (D_Z));
    			END;
    		END;
    
    		PROCEDURE Cancel_Handler;
    		BEGIN
    		END;
    	BEGIN
    		CASE Item of SetUpDialogC: Dialogue_A_Settings;
    			01	: Confirm_Handler;
    			02	: Cancel_Handler;
    		END;
    	END;
    BEGIN
    	Layout_Dialogue_A;
    	IF VerifyLayout (Dial_ID) THEN Dial_Res := RunLayoutDialog (Dial_ID, Dialogue_A_Handler);
    END;
    
    PROCEDURE Dialogue_B;
    BEGIN
    	AlrtDialog ('Here''s nothing going on');
    END;
    
    BEGIN
    vsoGetEventInfo (Event, Result);
    CASE Event OF
    	k_Icon:
    	BEGIN
    		Bool	:= SetObjPropVS (PIO_Controls_Palette, TRUE);
    		Bool	:= vsoInsertAllParams;
    		Bool	:= vsoAppendWidget (12, 100, 'Button 1', 0);
    		Bool	:= vsoAppendWidget (12, 200, 'Button 2', 0);
    	END;
    
    	k_Palette_Button:
    	CASE Result OF
    		100:	Dialogue_A;
    		200:	Dialogue_B;
    	END;
    
    	Reset_PIO:
    	IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    	BEGIN
    		PushAttrs;
    			Result_A;
    			Result_B;
    			Records;
    			Record (PIO_H, 'Rec_N');
    		PopAttrs;
    	END;
    END;
    END;
    RUN (Point_Object);
    

  13. The endgoal would be a drawing-border with titleblock, since VectorWorks 2014-Fundamentals no longer supports this - fairly handy - bluid-in plugin anymore

    (Why would someone using Fundamentals not use the remarks & revisions part?)

    Actualy, it was no longer supported since VW 2009 or 2010, but with some basic "trickery" I was able to use older plugin.

    Due to some obsolete functions in that plugin it became problematic, so the general plan is a better (to my personal requirements), more complete drawing-border + titleblock plugin.

    Some extra features would be:

    _ a legend, based on the used hatches, linetypes and symbols (see code in this topic + some ListBrowser functions);

    _ a firm-selector (in use);

    _ better - metric - dimensions (in use);

    _ better folding marks (Work In Progress (W. I. P.));

    _ automatic field updates (drawing name, drawing date, drawing number of total number of drawings, ...) (in use)

    _ Re-enabled remarks-section (another button in OIP, W. I. P);

    _ Re-enabled revisions-section (another button i the OIP, W. I. P.);

    _ ...

    I've tried the Python-editor but encountered some - really irritating - problems:

    When the editor displayed an error and the error was fixed correctly in the script, the editor kept displaying this error untill the the editor was restarted.

    I must say: I haven't checked if this problem is solved by now (or maybe I missed something else, since I don't really know the Python-language).

  14. Of course I didn't, but I do believe this is another option Hippothamus suggested in his post from 05/20.

    In the actual PIO (of which this code is just a part) there is already a record being created, I was able to integrate these fileds into that record, so stricktly spoken there is no extra record being created.

    Considering there might easily about 20 booleans being created in this part:

    _ Is there a major disadvantage in using records?

    _ Is there a limit to the number of fields?

    I was hoping to keep a clear view by using different (Dyn)Arrays.

    And by the way: these suggestions are never too late, there are no lives at stake, I'm just in an everlasting learning-proces, so the're always welcome.

  15. This should be a bit better:

    PROCEDURE PIOButtonInOIP;
    CONST
    Reset_PIO	= 03;
    PushIcon	= 05;
    PushButton	= 35;
    CR			= Chr (13);
    VAR
    PIO_N					: STRING;
    PIO_H, PIO_R, PIO_W		: HANDLE;
    Event_Id, Event_Result	: LONGINT;
    Dial_Id, Dial_Result	: LONGINT;
    Result					: BOOLEAN;
    Bool, Item				: ARRAY [1 .. 2] OF BOOLEAN;
    
    PROCEDURE Dialog;
    	PROCEDURE DialogLayout;
    	BEGIN
    		Dial_Id	:= CreateLayout ('Custom Dialog Box', TRUE, 'OK', 'Cancel');
    		CreateCheckBox (Dial_Id, 04, 'Draw Rectangle A');
    		CreateCheckBox (Dial_Id, 05, 'Draw Rectangle B');
    
    		SetFirstLayoutItem	(Dial_Id, 04);
    		SetBelowItem		(Dial_Id, 04, 05, 0, 0);
    	END;
    
    	PROCEDURE DialogEvents (VAR Item: LONGINT; Data: LONGINT);
    		PROCEDURE DialogSettings;
    		BEGIN
    			SetBooleanItem (Dial_Id, 04, Bool [1]);
    			SetBooleanItem (Dial_Id, 05, Bool [2]);
    		END;
    
    		PROCEDURE EventOK;
    		BEGIN
    			GetBooleanItem (Dial_Id, 04, Bool [1]);
    			GetBooleanItem (Dial_Id, 05, Bool [2]);
    
    			NewField ('Bools', 'Item [1]', Concat (Bool [1]), 2, 1);
    			NewField ('Bools', 'Item [2]', Concat (Bool [2]), 2, 1);
    
    			IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    			BEGIN
    				SetRField (PIO_H, 'Bools', 'Item [1]', Concat (Bool [1]));
    				SetRField (PIO_H, 'Bools', 'Item [2]', Concat (Bool [2])); 
    			END;
    		END;
    
    		PROCEDURE EventCancel;
    		BEGIN
    		END;
    	BEGIN
    		CASE Item OF SetupDialogC: DialogSettings;
    			01: EventOK;
    			02: EventCancel;
    		END;
    	END;
    BEGIN
    	DialogLayout;
    	IF VerifyLayout (Dial_Id) THEN Dial_Result := RunLayoutDialog (Dial_Id, DialogEvents);
    
    	IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    	Message ('Bool [1] = ', Bool [1], CR, 'Bool [2] = ', Bool [2], CR, CR, 'Item [1] = ', GetRField (PIO_H, 'Bools', 'Item [1]'), CR, 'Item [2] = ', GetRField (PIO_H, 'Bools', 'Item [2]'));
    END;
    
    PROCEDURE Geometry;
    BEGIN
    	IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    	BEGIN
    		Record (PIO_H, 'Bools');
    		IF GetRField (PIO_H, 'Bools', 'Item [1]') = 'True' THEN Rect (0,  0, 20, 10);
    		IF GetRField (PIO_H, 'Bools', 'Item [2]') = 'True' THEN Rect (0, 15, 20, 25);
    	END;
    END;
    BEGIN
    vsoGetEventInfo (Event_Id, Event_Result);
    CASE Event_Id OF
    	PushIcon: 	BEGIN
    					Result	:= SetObjPropVS (08, TRUE);
    					Result	:= vsoInsertAllParams;
    					Result	:= vsoAppendWidget (12, 100, 'Button', 0);
    				END;
    
    	PushButton:	CASE Event_Result OF
    					100:	Dialog;
    				END;
    
    	Reset_PIO:	Geometry;
    END;
    ResetObject (PIO_H);
    END;
    RUN (PIOButtonInOIP);
    

    This creates geometry inside the PIO after the PushButton-Event.

    I'm sure the code is liable for improvements, so if anyone would care to make the efford, please do so (again ...)

    Thanks for all the suggestions.

    Next question/topic will be about storing the data in the 'Item [ ]-fields'.

    @Hippothamus:

    Before calling these DynArrays my friend, I guess I'll have to get acquainted to them ...

  16. Josh,

    What if one doesn't know how many parameters will be used in the PIO?

    Since you have to define (i. e. name) all the __parameters in the parameter setup, you should know - at least - how many parameters will be used, which I don't.

    That is why I tried to write them to a Record, because I think (so, I'm not sure) that it's possible to write an undefined number of fields to a record.

    I think this is what Hippothamus suggested.

    For now, I'll experiment a bit with your - very helpful - suggestions and see where it takes me.

    Thanks.

  17. Well ... I've tried some different scenario's, but ...

    Hope you don't me dropping some code of one them (Point Object):

    PROCEDURE PIOButtonInOIP;
    CONST
    Reset_PIO			= 03;
    PushIcon			= 05;
    PushButton		= 35;
    VAR
    PIO_N				: STRING;
    PIO_H, PIO_R, PIO_W		: HANDLE;
    Event_Id, Event_Result	: LONGINT;
    Dial_Id, Dial_Result		: LONGINT;
    Result				: BOOLEAN;
    Bool, Item				: ARRAY [1 .. 2] OF BOOLEAN;
    
    PROCEDURE Dialog;
    	PROCEDURE DialogLayout;
    	BEGIN
    		Dial_Id	:= CreateLayout ('Custom Dialog Box', TRUE, 'OK', 'Cancel');
    		CreateCheckBox (Dial_Id, 04, 'Draw Rectangle A');
    		CreateCheckBox (Dial_Id, 05, 'Draw Rectangle B');
    
    		SetFirstLayoutItem	(Dial_Id, 04);
    		SetBelowItem		(Dial_Id, 04, 05, 0, 0);
    	END;
    
    	PROCEDURE DialogEvents (VAR Item: LONGINT; Data: LONGINT);
    		PROCEDURE DialogSettings;
    		BEGIN
    			SetBooleanItem (Dial_Id, 04, FALSE);
    			SetBooleanItem (Dial_Id, 05, FALSE);
    		END;
    
    		PROCEDURE EventOK;
    		BEGIN
    			GetBooleanItem (Dial_Id, 04, Bool [01]);
    			GetBooleanItem (Dial_Id, 05, Bool [02]);
    		END;
    
    		PROCEDURE EventCancel;
    		BEGIN
    		END;
    	BEGIN
    		CASE Item OF SetupDialogC: DialogSettings;
    			01: EventOK;
    			02: EventCancel;
    		END;
    	END;
    
    	PROCEDURE Bools;
    	BEGIN
    		IF Bool [01] = TRUE THEN NewField ('Bools', 'Item [01]', 'TRUE', 2, 1);
    		IF Bool [02] = TRUE THEN NewField ('Bools', 'Item [02]', 'TRUE', 2, 1);
    
    		IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN SetRecord (PIO_H, 'Bools');
    		IF Bool [01] = TRUE THEN SetRfield (PIO_H, 'Bools', 'Item [01]', 'TRUE');
    		IF Bool [02] = TRUE THEN SetRfield (PIO_H, 'Bools', 'Item [02]', 'TRUE');
    	END;		
    BEGIN
    	DialogLayout;
    	IF VerifyLayout (Dial_Id) THEN Dial_Result := RunLayoutDialog (Dial_Id, DialogEvents);
    	Bools;
    END;
    
    PROCEDURE Geometry;
    BEGIN
    	IF GetCustomObjectInfo (PIO_N, PIO_H, PIO_R, PIO_W) THEN
    	BEGIN
    		IF GetRField (PIO_H, 'Bools', 'Item [01]') = 'TRUE' THEN Rect (0, -75, 100, -25);
    		IF GetRField (PIO_H, 'Bools', 'Item [02]') = 'TRUE' THEN Rect (0, 25, 100, 75);
    		Message ('Item [01]: ', Item [01], Chr (13), 'Item [02]: ', Item [02]);
    	END;
    END;
    BEGIN
    vsoGetEventInfo (Event_Id, Event_Result);
    CASE Event_Id OF
    	PushIcon: 		BEGIN
    					Result	:= SetObjPropVS (08, TRUE);
    					Result	:= vsoInsertAllParams;
    					Result	:= vsoAppendWidget (12, 100, 'Button', 0);
    				END;
    
    	PushButton:	CASE Event_Result OF 
    					100:	Dialog;
    				END;
    
    	Reset_PIO:		BEGIN
    					Geometry;
    				END;
    END;
    END;
    RUN (PIOButtonInOIP);
    

    The OIP tells me that Item [01] & [02] are TRUE, but the Message ( ) tells me the're FALSE, so I know there's something(s) fundamentally wrong.

    (By the way, is anybody else experiencing some trouble with the 'Preview Post' on this forum while posting?)

  18. @ Mr. Dunning,

    I wasn't very clear on that one.

    The values aren't lost when exiting the Dialog, but do seem to be lost when re-entering the Dialog.

    @ Mr. Geerts,

    For now I'm trying to use the SetRField to control 1 hidden parameter, I was hoping that this parameter could control all the different booleans from the Dialog, but apparently, "that kite won't go up", for now.

    @ Mr. Benghiat,

    Could it be that the Dialog behind the Button of the PIO is being reset after exiting, not the PIO itself?

    The PIO (and its different button-parts) should keep it's properties per Sheet-Layer, but I guess that criterium wouldn't be that hard to script ...

  19. Probably trying too much too fast, but ...:

    How can I reset the PIO and keep the changes executed by the button-click-event?

    If I click the button that opens a Custom Dialog Box - containing some boolean items - and change some of these items, then after I close this dialog box, the PIO is being reset bij the kResetObject-event.

    By resetting the object all the boolean items go back to their initial vanlue (seems logical), but how can I maintain these changes in the memory of the PIO?

    (Meanwhile, I guess I'd better start looking up on how to store stuff in a Dynamic Array ...)

  20. Yes, but that would be the easy way out if it were not, that the legend would just be a part of the plugin,

    and also, the plugin wouldn't answer the initial question.

    Basically, still trying to understand these Events ... but thanks anyway.

  21. I've opted the second option (I think):

    Let the script look for hatches & line patterns in a ListBrowser and then display all the results in the legend using one simple standard Boolean parameter ('Show Legend').

    This should also answer your question:

    The geometry would consist of some hatched rectangles, some patterned lines, perhaps some symbols and some text explaining the forementioned.

    Anyway the first option might answer the initial question: "How to create geometry inside a PIO by pushing a button".

    The current Dialogbox appearing after pushing the button creates the desired geometry, but it does so outside the PIO.

    If I understand you correctly, the button shouldn't control some Procedure(s) in the script, but should control parameters that control some Procedure(s) in the script.

    Thanks.

×
×
  • Create New...