Jump to content

Gibson431

Member
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Gibson431

  1. Is there a way to use relative / posix paths to include files one folder down? I am attempting to organise a fairly involved plugin that ideally references files in a hierarchical structure e.g.: plugin.vso modules/ module1.px module2.px models/ model1script.px model2script.px I can easily import files in the same same level as the plugin folder but attempting to include any files further down don't seem to be recognised. My best guess is that this is a quirk of the version of pascal VectorScript is but unfortunately I can't move to python. Thanks
  2. Unfortunately this code is just an analog of the task I need to do. The grid of squares if just the way I decided to visualise the program. All it boils down to is being able to create a variable number of parameters based on input, and having them populate on object creation as well as be individually editable by the user in the OIP (or dialog in this case).
  3. This is really useful, thank you so much! I will not lose hope!
  4. I am attempting to create a point object plugin that generates a grid of boxes based on variable inputs for number of rows and number of boxes in each row. I have managed to make the plugin draw the grid after a dialog has been opened however I can't figure out how to get it to draw the grid on creation. I have the plugin set to event enabled with resets on for both move and rotate. I believe my issues are stemming from overriding the default behaviour for object events. Here is my program PROCEDURE testing; CONST {Event ID's} kEventID_ParametricRecalculate = 3; kEventID_OnObjPref = 4; kEventID_OnInitProperties = 5; kEventID_OnDoubleClick = 7; kEventID_OnUIButtonHit = 35; kEventID_OnAddState = 44; {Notification ID's} kNotifID_CreatedReset = 0; kNotifID_MovedReset = 1; kNotifID_RotatedReset = 2; kNotifID_ParameterChangedReset = 3; {permissions} kObjXPropHasUIOverride = 8; kObjXPropAcceptStates = 18; kDialogIDOffset = 4; kWidgetButton = 12; kButtonID = 1234; VAR objEvent, eventData :LONGINT; objH, recH, wallH, tempH :HANDLE; objName, recName :STRING; gDialogID :INTEGER; gNumEntries :INTEGER; gWidth, gHeight, gPadding :REAL; gVarArr :DYNARRAY[] of INTEGER; result :BOOLEAN; PROCEDURE DrawBoxes; var i,j, rowLength :INTEGER; rowStr : dynarray[] of char; isEmpty, isLinked :boolean; BEGIN result := GetCustomObjectInfo(objName, objH, recH, wallH); recName := getName(recH); if (objH <> nil) then {<--- seems to have an object usually} begin for i := 0 to gNumEntries-1 do BEGIN {vvv this is always an empty string until dialog is opened vvv} rowStr := GetRField(objH, recName, Concat('_',num2str(0,i))); rowLength := Str2Num(rowStr); for j:= 0 to rowLength-1 do BEGIN if rowLength <> 0 then Rect( j*(gWidth+gPadding), i*(gHeight+gPadding), j*(gWidth+gPadding)+gWidth, i*(gHeight+gPadding)+gHeight); end; END; end else AlertCritical('tried and failed', ''); {<--- never triggers} END; PROCEDURE DialogHandler(VAR item:LONGINT; data:LONGINT); VAR i, val :integer; BEGIN CASE item OF 1: BEGIN for i:= 0 to gNumEntries-1 do BEGIN result := GetEditInteger(gDialogID, (i*2)+kDialogIDOffset+1, val); SetRField(objH, recName, Concat('_', num2str(0,i)), Num2Str(0,val)); end; end; end; END; PROCEDURE DialogGenerator; var actionItem :LONGINT; result :BOOLEAN; i, tempVal :INTEGER; tempStr :dynarray[] of char; begin result := GetCustomObjectInfo(objName, objH, recH, wallH); gDialogID := CreateLayout('Boxes per Row', FALSE, 'OK', 'Cancel'); for i:= 0 to gNumEntries-1 do BEGIN CreateStaticText(gDialogID, (i*2)+kDialogIDOffset, concat('Row ', num2str(0, i+1)), 16); tempStr := GetRField(objH, recName, Concat('_',num2str(0,i))); {vvv creates parameters here for some reason vvv} if tempStr = '' then {if parameters don't exist yet} begin NewField(recName, Concat('_',num2str(0,i)), Num2Str(0,gNumEntries), 1,0); tempStr := Num2Str(0,gNumEntries); end; {^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^} CreateEditInteger(gDialogID, (i*2)+kDialogIDOffset+1, Str2Num(tempStr), 16); END; SetFirstLayoutItem(gDialogID, kDialogIDOffset); SetRightItem(gDialogID, kDialogIDOffset, kDialogIDOffset+1, 0, 0); for i:= 1 to gNumEntries-1 do BEGIN SetBelowItem(gDialogId, (i*2)+kDialogIDOffset-2, (i*2)+kDialogIDOffset, 0, 0); SetRightItem(gDialogId, (i*2)+kDialogIDOffset, (i*2)+kDialogIDOffset+1, 0, 0); END; actionItem := RunLayoutDialog(gDialogID, DialogHandler); end; PROCEDURE init; var i :integer; tempStr :dynarray[] of char; begin gNumEntries := PNumber_Of_Rows; gWidth := Pw; gHeight := Ph; gPadding := PPadding; result := GetCustomObjectInfo(objName, objH, recH, wallH); recName := GetName(recH); end; PROCEDURE setup; var i :integer; tempStr : dynarray[] of char; begin result := SetObjPropVs(kObjXPropHasUIOverride, true); if result = false then AlertCritical('Error','Failed to override UI'); result := SetObjPropVs(kObjXPropAcceptStates, true); if result = false then AlertCritical('Error','Failed to accept states'); result := vsoInsertAllParams; if result = false then AlertCritical('Error', 'There was an issue inserting parameters.'); if vsoAppendWidget(kWidgetButton, kButtonID, 'Select Columns', 0) = false then AlertCritical('Error', 'button broke'); result := GetCustomObjectInfo(objName, tempH, recH, wallH); {<--- this always fails} if result = false then begin message('setup failed'); end; recName := GetName(recH); if (objH <> nil) then {<--- this never triggers as GetCustomObjectInfo always fails} begin for i:=0 to gNumEntries-1 do begin if GetRField(objH, recName, Concat('_',num2str(0,i))) = '' then begin NewField(recName, Concat('_',num2str(0,i)), Num2Str(0,gNumEntries),1,0); end; end; end; end; procedure CheckRecalculations; var outWidgID : LONGINT; outPrmIdx : INTEGER; outOldVal : STRING; i, oldInt : INTEGER; begin {vvv never runs vvv} if vsoStateGetParamChng(objH, outWidgID, outPrmIdx, outOldVal) then begin if (outPrmIdx = 1) then begin oldInt := Str2Num(outOldVal); if (oldInt < gNumEntries) then for i:= oldInt-1 to gNumEntries-1 do NewField(recName, Concat('_',num2str(0,i)),Num2Str(0,gNumEntries),1,0); end; end; if vsoStateGet(objH, kNotifID_CreatedReset) then {<--- never runs} begin setup; end; end; BEGIN init; BeginGroup; vsoGetEventInfo(objEvent, eventData); CASE objEvent OF kEventID_OnInitProperties: setup; kEventID_OnUIButtonHit: DialogGenerator; kEventID_ParametricRecalculate: begin CheckRecalculations; DrawBoxes; vsoStateClear( objH ); end; kEventID_OnAddState: eventData := vsoStateAddCurrent( objH, eventData ); END; EndGroup; ResetObject(objH); end; Run(testing); Things I've tried: Adding the parameter creation code to the draw procedure - works in drawing the boxes but the defaults end up being random numbers ("-823648", "2893659") using CreateCustomObject - draws the grid on creation but in the origin and not part of the plugin using SetCustomObjectPath and setting it to FSActLayer - completely fails (im not really sure what the FSActLayer is, I was just following the function reference's example) To my understanding, the object has not actually been created yet in the initProperties event (5) which means I can't access its record to initialise the properties. This makes no sense and I'm almost certain I'm missing something. Any help would be greatly appreciated!
×
×
  • Create New...