Jump to content

SamIWas

Member
  • Posts

    409
  • Joined

  • Last visited

Posts posted by SamIWas

  1. I learned Vectorscript by starting with very simple scripts I could find online and parsing what each line meant.  I also used the Function Reference, which has plenty of examples, and later the Language Guide, which also has a lot of examples.  I would try a new function every time I wrote a script and see how it worked.  And, I would ask questions on this forum.  I now write script consistently.  
     

    The only thing that pisses me off is the years-long bug that arbitrarily limits the number of scripts you can have in the object context menu...a lot of them simply will not run.  That alone has made me question upgrading further.

  2. Amongst others, I have a power service and phase field in my Lighting Device records.  Once I assign the correct info to each fixture, I can get a report of how much is used on each service and phase.

     

    All my data imports into filmmaker, where I use a custom database with scripts which can auto-generate phases for any given rack when given a circuit number.  This then gives a detailed report of power usage.

    • Like 2
  3. 2 hours ago, Benson Shaw said:

    •And many thanks to denizens of this forum for patience, encouragement, education, discussion and help in many ways with questions, issues, and general vwx practice.  I'm still a klutz with limited knowledge of the software, but through this forum, my klutziness is reduced and my limits are expanded.  Bravo to all!

     

    19 minutes ago, zoomer said:

    And the Forum is a wonderful source of knowledge and help.

     

    I agree with both of these.  Any question I ask on this forum, I almost always get someone trying to help, even if it takes multiple posts to do so.  And in the case of my question about Vectorscript Custom Dialogs, it opened up a whole new level of possibilities that I've been wanting to learn for years.  Also, this forum has active participation from the developer, and they seem to actively look at troubleshooting and bug submissions.  You can't beat that.

     

    Contrast this to the forum for another piece of software I use where I have been told on many occasions that I need to not ask questions, but rather go and learn.   IN fact, the answer to one question on how to best accomplish a complex scripting action, I was told "Think about what you want to do, and then go figure out how to do it".  Not very helpful at all.  And the developer does not seem to respond to anything on the forum.

  4. I second Pat's advice.  I'm not nearly as advanced as others, but I can write a mean script.  I learned it all from starting with something very simple, looking at other scripts and parsing how they worked, and spending a LOT of time looking at the function reference document.  The function reference document has examples for many of the functions, and that will give you ideas as you go.

  5. 11 hours ago, sww1235 said:

    Thank you everyone for all your help. This forum is probably one of the most helpful I have ever participated in.

     

    Agreed.  This made me remember my opposite experiences from the support forum for another piece of software I use a lot.  One time, I posted asking about how to achieve a certain result by combining some records in a database, and the response I got from multiple people was "Why don't you think about what you want to do and then figure out a way to achieve that".  Super helpful.  

  6. 59 minutes ago, rDesign said:

    @SamIWas- I found this other thread about this same issue. The latest post gives some instructions on how to possibly fix it. As the error message indicated, it sounds like a Permissions issue. HTH.

     

    Thank you!  Don't know how i didn't see that thread.  It does indeed seem to be a permissions issue, and you have to set them on every folder within Libraries in the application folder.

  7. Every time I start Vectorworks, it tells me I have libraries that are available for download/updating.  Yet, every time I tell them to update, I get an error message saying that I can't.  I have a feeling this is related to the fact that when I first tried to download the libraries, I was on the slow internet at work, and had to cut it off.  Any idea how to rectify this?  Do I just need to hunt down the existing libraries and delete them, then start over?

     

    vwerror.jpg

  8. Someone else might correct me, but I'm pretty sure you need to create a separate label legend for this.  This would be for several reasons.  Mostly, when you flip a fixture and the legend has two fields which combine, such as circuit name and number, then those would reverse upon a flip.  

  9. 10 minutes ago, Pat Stanford said:

    The work around is to use the ForEachObject command and an appropriate criteria to process the objects.

     

     

     

    Was wondering about ForEachObject, but since the function reference guide states that it's essentially the same as writing a NextSObj loop, I thought it might not work.  But I guess I will go test more of that.

  10. I've always used h:=NextSObj or h:=NextObj in loops to run a script across a series of items.  While updating my scripts, I'm trying to get them to work across layers if layers are set to Show/Snap/Modify.  Selection works across the layers, reporting the number of selected items world across layers, but NextObj and NextSObj do not.  Is there another procedure I should be using?

  11. I've posted about this a few times over the past few years, but this has been going on for more years than that.  I think 2014 was the first time I noticed these issues.

     

    I like to write a lot of shortcut scripts to greatly speed up my workflow.  It used to work very well for me.  But, at some point, it just randomly stopped working.  I was hoping that 2017, and starting fresh without importing any settings or plugins (re-writing all of them) would see the issue solved.  But alas, we're back at square one.

     

    Tonight, I created my second menu under the "Object Context" menu, and dropped two known-working scripts into it.  They did not function.  Moved them to another location, and they ran fine.  

     

    I remember JimW responding to this issue, but can't seem to find it.  I would really like to know what the limitations of the workspace menus are so that I can craft my workspace to work the best for me, and not just hope that any given menu will work any given day.  This has been killing me for four years now.  Is there any chance of it getting fixed or is it time to just give up on heavy customization?

  12. 15 minutes ago, MullinRJ said:

    Hello Sam,

       You need to make IUniv a variable parameter in your function declaration of MyDialog().

     

    change:

    function Mydialog(var lValue, lAddr :integer; lUniv :STRING) :boolean;

    to:

    function Mydialog(var lValue, lAddr :integer; var lUniv :STRING) :boolean;

     

       That's it.

     

    Raymond

     

     

    Holy crap.  That did it.  I would have never figured that out.  Didn't realize you had to declare VAR again for each new type.  Weird that the compiler doesn't catch that.

     

    Thank you so much everyone!  I think I have the basics down and can get started making some new dialogs!

  13. Okay...I'm 95% comfortable with what's going on now.   I've got variables passing between the main part and the dialog handler, and reporting at the end.  The only exception is the text field, ID 6 (it's a text field just for testing purposes).  It doesn't pass to the message at the end.   Everything else works as intended, and I think I have the dialog handler written more correctly.

     

    So, if you can point me where I'm going wrong on the text field, I will owe you my eternal gratitude, and hopefully put this thread to a close!

     

    Procedure AssignInfo; 
    
    var
    	gValue,gAddr: integer;
    	gUniv:STRING;
    
    function Mydialog(var lValue,lAddr:integer;lUniv:STRING):boolean;
    
    VAR
    
    	id :INTEGER;
    	result  :INTEGER;
    
    
    	PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);
    		var Bool: boolean; 
    		tUniv:String;
    		tAddr:integer;
    
    		BEGIN
    		CASE item OF
    			SetupDialogC:
    				BEGIN
    					SetItemText(id,6,'0');
    					SetEditInteger(id,7,0);
    					SetBooleanItem(id,8,TRUE);
    				END;
    			1:
    				BEGIN
    					GetItemText(id,6,lUniv);
    					If GetEditInteger(id,7,TAddr) then lAddr:=TAddr;
    					GetBooleanItem(id, 8, Bool); if Bool THEN lValue := 1;
    				END;
    			2:
    				BEGIN
    				END;
    		END; {case}
    	END; {Dialog Handler}
    
    BEGIN
    	id:=CreateLayout('Assign Address',TRUE,'Apply','Cancel');
    	
    	CreateStaticText(id,4,'Assign Universe:',-1);
    	CreateStaticText(id,5,'Assign Address:',-1);
    	CreateEditText(id,6,'0',6);
    	CreateEditInteger(id,7,0,6);
    	CreateCheckBox(id,8,'Use three digits for address');
    	
    	SetFirstLayoutItem(id,4);
    	SetRightItem(id,4,6,0,0);
    	SetBelowItem(id,4,5,0,0);
    	SetRightItem(id,5,7,0,0);
    	SetBelowItem(id,5,8,0,0);
    	
    	SetHelpText(id,6,'Enter Universe');
    	SetHelpText(id,7,'Enter DMX Address  ');
    	SetHelpText(id,8,'Convert DMX address to 3 digits. Example: 45 = 045');
    
    	result := RunLayoutDialog(id, Dialog_Handler);
    
    	if result = 2 then Mydialog := false else Mydialog := true;
    END; {Mydialog}
    
    begin {main} 
    
    	if Mydialog(gValue,gAddr,gUniv) then
    		begin
    
    		message('Universe is ',gUniv,' / Address is ',gAddr,' / Checkbox value is ',gValue);
    
       end;
    end; {main} 
    
    run(AssignInfo);

     

  14. 3 hours ago, JBenghiat said:

    First off, this example is a little non-standard, and the dialog handler really isn't a proper handler, and will only work for demonstration purposes.  This may not actually be a great example to try and emulate.

     

    The argument in Mydialog() has the keyword VAR in front of it, and would be a pointer in other programming languages: lValue doesn't actually store a LONGINT, but rather the address of another LONGINT variable.  In this case, when you pass gValue to Mydialog, Mydialog effectively substitutes the variable name gValue every time you see lValue.  It's a bit of a cleaner way to deal with scope, though because the dialog handler takes specific arguments, lValue really becomes a global in Mydialog.

     

    The answer to your question of fetching the text value depends on the scope where you need it.  Let's say you want to just extend this example 

     

    In the scope of test, define the variable:

    gTxtValue :STRING;

     

    Define the function Mydialog as:

    function Mydialog(VAR lValue :integer; VAR lTxtValue :STRING) :boolean;

     

    Call mydialog:

    ...Mydialog(gValue, gTxtValue)...

     

    and of course retrieving the field value would be:

    GetItemTextID(id, 8, lTxtValue);

     

    The dialog handler here is fairly incomplete, as you constantly retrieve values for every dialog event.  You really want a CASE statement so that the right part of the code executes for each "item" with which the user interacts.  Retrieving the values into your globals would only be in the case that the user clicks the OK button, item = 1.

     

    Your questions seem to be more related to VectorScript variables and scope rather than dialogs specifically, so I highly recommend starting here for the language fundamentals: http://developer.vectorworks.net/images/7/72/VectorScriptGuide.pdf  VS is based on Pascal, so you can also investigate Pascal basics, though note that VS is a proprietary version of the language.  If you are new to programming in general, I recommend learning Python instead.  The VS and Python API have identical commands, but with Python you are learning a contemporary programming language with a simpler syntax.

     

    HTH,
    Josh

     

    Thanks for the info Josh...I'll keep plugging along using your help above.  

     

    I knew it probably wasn't the best example, but simpler examples have been hard to find.  And what you see above is after I cleaned up the spacing, tabs, and lines!

     

    Not really new to programming.  I've written over 100 VectorScripts so far to do all sorts of things, including my own custom GrandMA exporter (because I don't like the official one).   So far, I've used the standard built-in dialogs.  There's just something about the way this custom dialog thing works that isn't connecting in my brain.  Seems like it could be so much simpler!

     

  15. I've been experimenting some more, and decided that the examples I was working with were too complicated to learn from.  So I found a much simpler one, but still have a question or two...

     

    -------------------------------------------------------------

    Procedure test; 

     

    var

        gValue : integer;

     

    function Mydialog(var lValue:integer):boolean; VAR

     

      id :INTEGER;

      result  :INTEGER;

     

     

     

    PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);

        var Bool: boolean; 

        

        BEGIN

     

            GetBooleanItem(id, 5, Bool); if Bool THEN lValue := 0;

            GetBooleanItem(id, 6, Bool); if Bool THEN lValue := 2;

            GetBooleanItem(id, 7, Bool); if Bool THEN lValue := -1;

        END;

     

    BEGIN

     

        id := CreateLayout('Set Visibility', FALSE, 'OK', 'Cancel');

        CreateGroupBox(id,4,'Visibility:',true);

        CreateRadioButton(id,5,'Show');

        CreateRadioButton(id,6,'Grey');

        CreateRadioButton(id,7,'Hide');

     

        SetFirstLayoutItem(id,4);

        SetFirstGroupItem(id,4,5);

        SetBelowItem(id,5,6,0,0);

        SetBelowItem(id,6,7,0,0);

     

        result := RunLayoutDialog(id, Dialog_Handler);

     

        if result = 2 then Mydialog := false else Mydialog := true;

    END; {Mydialog}

     

    begin {main} 

     

        if Mydialog(gValue) then

     

            begin

            message(concat(gValue));

     

       end;

    end; {main} 

     

    run(test);

     

    -------------------------------------------------------------

    So, the part that is blue is a no-brianer.  Not worried about that at all.  I'll start with questions...

     

    gValue is specified as a variable for procedure "test" as an integer.  But, nowhere in the script is gValue given a value.  During a function, a value is given to variable lValue.  But at the end of the script, a message displays gValue with the value given to lValue.   Where is gValue being given its value from lValue?  

     

    In Procedure Dialog_Handler, I know i can add in GetItemText calls to retrieve strings from CreateEditText boxes and GetEditInteger/Real calls to retrieve numbers from CreateEditInteger/Real boxes in the layout.  I assume that I need extra variables of String, Integer, and Real types to collect the info.  So, let's say I do the following (changes in red)

     

    function Mydialog(var lValue:integer;univ:string):boolean; VAR

     

      id :INTEGER;

      result  :INTEGER;

     

    PROCEDURE Dialog_Handler(VAR item :LONGINT; data :LONGINT);

        var Bool: boolean; 

        

        BEGIN

            GetItemText(id, 8, univ);

            GetBooleanItem(id, 5, Bool); if Bool THEN lValue := 0;

            GetBooleanItem(id, 6, Bool); if Bool THEN lValue := 2;

            GetBooleanItem(id, 7, Bool); if Bool THEN lValue := -1;

        END;

     

     

    How does univ get passed down?  Did I even put univ in the right place?  At some point, something is going to click, and I'll be able to fully grasp what is going on start writing more complex dialogs.

  16. I know I've asked about it before, but now we have an official wishlist and voting system.

     

    I'd like to see the keyboard shortcut system completely redone.  As it stands almost every combination of keys is used by VW already.  And what remains uses three modifier keys for the most part.  This makes it difficult for those who write a lot of shortcut scripts and would like to have keyboard shortcuts for them, especially to map to external shortcut systems.  It also makes them hard to remember when your channel assign script is command-option-control-w or something, since that letter has no relation to channel.

     

    In my opinion, Cinema 4D has the best shortcut system.  In addition to normal modifiers, you can have two-key combinations, almost like category shortcuts.  So, say I was assigning Lighting Device parameters, I could press L then C, and that would run my "Assign Channel" script.  L-D would run my "Assign Dimmer" script.  L-P for "Purpose".   Cable Tools could have a category.   Walls could have a category.  Instead of the current 150 or so possibilities, it opens up hundreds more possibilities.

     

    I guess I could see how it might be daunting, or that a script could ruin your day by accidental typing, but I'd still love something to be done.

    • Like 2
×
×
  • Create New...