Jump to content

SamIWas

Member
  • Posts

    409
  • Joined

  • Last visited

Posts posted by SamIWas

  1. 4 hours ago, Jesse Cogswell said:

    @_c_ Had some success with this in Python.  The same idea should carry over in Vectorscript since the Python implementation just adds a vs. prefix to the Vectorscript commands.

     

     

    Oof....I feared that this might require event enable.  That is just something I have not wrapped my head around yet.  Maybe one day...

  2. Is there a way to create collapsible sections in the OIP for a PIO object, such as in the door object shown in the image?  Or is that something available only through the SDK?  I have a PIO that I have written which has a lot of different sections, and it can get confusing without a visual divider of sorts.   I would love to be able to collapse unused sections.

     

    image.png.edc0ef3d0bac5129a1eba72f112af5d5.pngimage.png.0c59090d745e5dfaf742b837c6fdaec3.png

  3. 3 hours ago, JBenghiat said:

    In theory, you can place a hanging position PIO inside another PIO, though that would be a little complicated. And even then, you can’t easily attach objects to the hanging position. 
     

    You can probably do what you describe with the SDK. 

    That's what I figured.  That you.  The SDK is probably waaay out of my wheelhouse.

  4. I have written a PIO which has some pipe elements in it (just created using a sweep, but could do a different way).  Is there any way to make an object within a PIO act as a hanging position so that lighting devices would stick with it when the object moves?  And not just if the PIO moves, but if parts within the PIO move according to user input.

  5. 13 minutes ago, Pat Stanford said:

    OK, I found a work around that might work.  Convert the mesh to a solid, scale it, then convert back to a mesh.

     

    I THINK the reason that HScale3D does not work is that under the hood a Mesh is effectively a group of 3D polys. And HScale3D does not work on groups.

     

    Try this and see if it will fit your needs.

     

    Procedure Test;
    
    Var H1:Handle;
    	N1:Integer;
    
    BEGIN
    	ClosePoly;
    	BeginMesh;
    		Poly3D(-1,0,0, 1,0,0, 0,-1,1);
    		Poly3D(-1,0,0, 1,0,0, 0,-1,0);
    		Poly3D(-1,0,0, 0,-1,0, 0,-1,1);
    		Poly3D(1,0,0, 0,-1,0, 0,-1,1);
    	EndMesh;
    	N1:=AddSolid(LNewObj,LNewObj, H1);
    	HScale3d(H1, 0,0,0, 2,2,2);
    	DoMenuTextByName('Convert to Mesh', 0);
    	
    End;
    
    Run(Test);

     

    That did the trick.  Don't even need to convert it back to a mesh.  

  6. I went way outside my normal world and used vector script to create a mesh of an object which I couldn't build using standard script tools.  I built the object in Vectorworks, then exported it as a 3d vector script to get the mesh coordinates.  Then I added all that into a script that I am writing to build that part of the object.  That all works exactly as intended.  

     

    BUT,  I want to be able to scale that mesh with user input.  So, I added some scaling fields into the OIP.  Cool.  All that is great, except at the mesh doesn't scale.  

     

    Here's a general layout of the code:

     

    BeginGroupN(groupname);
       BeginMesh;
          ClosePoly;
          *a bunch of 3d poly coordinates*
       EndMesh;
       EndGroup;

     

    Now, I have tried HScale3d both just after EndMesh with LNewObj as the handle, and after EndGroup with "group name" as the handle.  Neither seems to have any effect.  Is there a step I'm missing here to scale a mesh overall?

  7. On 4/5/2022 at 8:30 PM, MullinRJ said:

    @The Hamma,

       Out of curiosity, how many scripts is too many? Ball park. I assume the limit depends on how many total items are in a workspace, but knowing how many scripts you added would be interesting to know. Also, were your scripts Menu Items, or Palette Scripts?

     

    Thanks,

    Raymond

    I think the number depends on the alignment of the planets, and it will change over time.  I used to have a massive workspace full of custom scripts which made my workflow exceptionally fast.  Then somewhere around 2015, workspaces started to break apart if there were too many scripts. Many just wouldn't run.  This lasted for years.  2021 seemed to fix it, and I loaded up my workspace again, and it worked well.  Then, over time, commands started to break, not work at all, or call up completely random other commands.  I've never figured out an actual number.  Hopefully, 2022 fixes it, but I'm not holding my breath.

  8. 23 hours ago, Pat Stanford said:

    What I really want it for is debugging.  Loop with a Message and a Wait so I can let the code run and look at values as it continues.  Useless for that in the current state.  So I use AlrtDialog(Concat(Blah, Blah1, Blah2)); and hit the enter key 1000 times.  😞

     

    We are the same....I really lament the loss of Message functionality for debugging.

    • Like 1
  9. On 2/27/2022 at 12:45 PM, Jesse Cogswell said:

    I have had some issues with ResetObject not properly working on Lighting Devices in versions 2020+.  In 2015, they added the LDevice_Reset(h:HANDLE) and LDevice_ResetVisual(h:HANDLE) which have helped in some instances.  You might try those.

    Man...it's been over a month since you posted this, but thank you.  I will try this!

  10. I wrote a script which does some spotlight lighting device numbering tricks that the Vectorworks numbering tool does not do.  It all works perfectly as intended.  But a friend testing it for me says that the instruments updated by the script do not update in the XML file which is used as the data exchange between spotlight and Lightwright.  He says a change in the OIP works, changes via the numbering tool work, and changes made via "edit divide" work, but changes made via the script do not.  Even after making other changes in the document, instruments numbered only by the script do not update.

     

    Is there some kind of syntax which can be used in a vector script to update the field for Lightwright?  I do not use Lightwright, so I can't look into it myself.

  11. So, say I have a script with a dialog where the user can input several values.  in this case, let's say it's a pull-down menu.

     

    What is the method used so that the next time the script is run, the last-chosen or last-inputted value is populated in the dialog?  I'm assuming it has something to do with string definitions or something, but I haven't delved into this yet.  Or maybe it's in the parameters?

     

    Example:  Script is run, and the dialog has an edit box named "Start" where the user enters "100" as the value.  The next time the script runs, I want "100" to be in that edit box.  Or if they choose "Channel" from a drop down, then "Channel" would be the chosen option next time.

  12. 3 hours ago, JBenghiat said:


    You can… but what are you trying to do? A solution may already exist. 

     

    Building a script where I can right click on a pipe, choose a fixture, then have the script place fixtures on the pipe at either a fixed distance or per specified degree along the curve of a curved pipe.  There are options between duplicate array, move by points, or align and distribute, but I don't believe any of them allows you to pick a pipe and a fixture and automatically distribute.    I know how to do all the aligning and placing, I can figure out the length and radius of pipes and feed them in, but following paths is the harder part.

     

    For instance, when using a curved lighting pipe, it's fairly straightforward to get the length and radius of the pipe (although dimension fields come in with very strange formatting), but there's nothing in the pipe records which indicate the starting and ending angle of the pipe, it's center of arc, or rotation, at least as far as I can find.  So, I figure I need to pull in the underlying arc to get its information.

  13. 12 hours ago, JBenghiat said:

    You can’t change the layout live, only hide, show, and disable items. You place your if/then in the dialog handler, where you can retrieve values and call ShowItem(). You can retrieve a value at any time in the handler loop, not just during the ok event. 

     

    12 hours ago, klinzey said:

    Typically you will use Swap Panes  to show different sets of controls depending on the options that are chosen in the dialog.

    This will give let you place different controls in the same location.

    https://developer.vectorworks.net/index.php/VS:CreateSwapPane

     

    Oooh...thanks guys, I will test these out.  I don't think the script I'm trying to write will work out because I'm not sure you can pull info from the underlying polygon/arc in a lighting pipe.  But, this still gives me some stuff to play with.

  14. Me again...sorry for flooding the forum, but I'm on a writing kick...

     

    So, in custom PIOs, it's easy to show/hide/grey etc different parameters in the OIP.

     

    I assume the same thing is possible in custom dialogs, as things like the door tool change options in the dialog depending on what is in other fields.  I'm looking to replicate that, but fear that it may be event-based or something, and I just can't wrap my head around that yet.

     

    I was hoping that a simple if/then statement would do it, but it appears to be more complicated than that, since I don't think it parses the field results until the OK button is hit.  Any pointers, or is this far more complicated than that?

    In the handler section....
    			SetupDialogC:
    				BEGIN
    					AddChoice(dialogid,7,'Angle',0);
    					AddChoice(dialogid,7,'Distance',1);
    					SetItemText(dialogid,9,GetLName(ActLayer));
    					FOR symindex:= 1 to numsyms DO symindex:= InsertImagePopupResource(dialogid, 5, symlist, symindex);
    				END;
    
    In the dialog section....
    
    
    		dialogid:=CreateLayout('Place Fixtures On Radius',TRUE,'Apply','Cancel');
    		CreateStaticText(dialogid,4,'Select Symbol:',15);
    		CreateThumbnailPopup(dialogid,5);
    		CreateStaticText(dialogid,6,'Mode:',15);
    		CreatePulldownMenu(dialogid,7,20);
    		CreateStaticText(dialogid,8,'Relative Angle:',15);
    		CreateEditReal(dialogid,9,2,0,10);
    		CreateStaticText(dialogid,10,'Length:',15);
    		CreateEditReal(dialogid,11,3,72,10);
    		
    		
    
    		SetFirstLayoutItem(dialogid,4);
    		SetRightItem(dialogid,4,5,0,0);
    		SetBelowItem(dialogid,4,6,0,0);
    		SetRightItem(dialogid,6,7,0,0);
    		GetSelectedChoiceInfo(dialogid,7,0,lindex,lmode);
    		IF lmode='Angle' THEN BEGIN
    			SetBelowItem(dialogid,6,8,0,0);
    			SetRightItem(dialogid,8,9,0,0);
    			END;
    		IF lmode='Distance' THEN BEGIN
    			SetBelowItem(dialogid,8,10,0,0);
    			SetRightItem(dialogid,10,11,0,0);
    			END;

     

  15. 9 hours ago, MullinRJ said:

    @SamIWas,

       After a little playing, I found one way to populate a Symbol Popup Menu:

    index := InsertImagePopupObjectItem(dialogid, menuID, SymNam);

     

       And it appears you can also use:

    index := InsertImagePopupResource(dialogID, kImagePopupID, listID, index);

    where you use one of the BuildResourceList commands to build a list of symbol definition names, though I haven't tried this explicitly.

     

    Have fun,

    Raymond

     

     

    Alright...I was able to get this to work well enough for now.  Can't figure out how to make it show only lighting devices, so in bigger documents, the list is huge.  But, it's at least a start.

     

    image.png.e8f8da824d3dbd89058803139334aa76.png

     

    What I was hoping for is something like this, but maybe it's not possible.

     

    image.png.02aa9f33bc968cd1d2ecc10cc020b8a8.png

     

    Thanks for the help so far!

     

     

  16. 8 hours ago, MullinRJ said:

    Hello @SamIWas,

      For your symbol popup item, look at:  CreateThumbnailPopup(dialogID, item_number);

    Sorry, I don't have any example code to populate it.

     

       I assume your LayerName popup menu is already populated, but if not, use:  
    GetChoiceCount(dialogID, menuID, Cnt);
    AddChoice(dialogID, menuID, 'menu item text', Cnt);

    in a loop to add items to the end of the menu. This code would go in the SetupDialogC section of the dialog handler.

     

       To select an existing menu item to be the chosen item, use:  SelectChoice(dialogID, menuID, menuPos, TRUE);

    where menuPos is the position of the Active Layer Name in your list. I believe counting in SelectChoice is 1-based, but if I'm wrong, it's 0-based. Easy enough to test.

    This code also goes in the SetupDialogC section of the dialog handler.

     

    HTH,

    Raymond

     

     

    Thanks...this has given me some stuff to look at.  The SelectChoice for the layer menu works better than what I had come up with.  It appears that it orders the list in alphabetical order, so now I'm just searching for the right way to find the alphabetical index of the layers.

     

    Man...the symbol stuff seems harder than I thought.  Figured there would be a symbol popup window like what appears in so many tools, but it looks like you have to build it.  ugh.

  17. Hey gurus...

     

    I wrote a script to place symbols (lighting devices) based on the position of a large container object and all of its settings.  It all works exactly how I want it to.  Right now, I'm using a couple of workarounds to get the correct final result, but I'd love to figure out a few sticking points.One is getting a symbol chooser in my dialog, and the other is how to populate the layer drop-down with the current layer.  Some notes are in the code below (only relevant parts of the entire code are shown).  I realize that it might not be up to real programmers type code.

     

    So, I thought CreateSymDispCtrlN or CreateSymbolDisplayControl might be the answer, but they display only images.  I would like to get the symbol drop-down menu seen in other tools and then be able to pass off the resulting symbol choice to the lsymbol variable. 

     

    The second issue is the layer dialog.  Choosing the layer and passing it to the llayer variable works fine and functions correctly  in the script.  I just want the menu to default to the current layer, but doing a SetItemText for that component caused weird issues with selecting, so I'm not sure that's it.

     

    Any pointers would be very appreciated!

     

    FUNCTION Mydialog(var lsymbol:STRING; var langle : REAL; var llayer : STRING ) : BOOLEAN;
    
    LABEL
    	99;
    
    VAR
    
    	dialogid, result : INTEGER;
    	iTest : REAL;
    
    	PROCEDURE Dialog_Handler(VAR item : LONGINT; data : LONGINT);
    	
    
    
    		BEGIN
    		CASE item OF
    			SetupDialogC:
    				BEGIN
    					***DOES SOMETHING NEED TO GO HERE TO POPULATE THE SYMBOL DIALOG??***
    					***I THINK SOMETHING NEEDS TO GO HERE TO POPULATE THE DEFAULT FOR THE LAYER DIALOG***
    				END;
    			1:		
    				BEGIN
    					GetItemText(dialogid,5,lsymbol);  ** THIS IS TEMPORARY UNTIL I CAN FIGURE OUT THE SYMBOL DIALOG AND HOW OT PASS THE RESULT
    					IF GetEditReal(dialogid,7,2,iTest) THEN langle:=iTest;
    					GetItemText(dialogid,9,llayer);
    				END;
    			2:
    				BEGIN
    				END;
    		END; {case}
    	END; {Dialog Handler}
    
    
    BEGIN
    
    		
    	
    		dialogid:=CreateLayout('Add Fixtures to Softboxes',TRUE,'Apply','Cancel');
    		
    		CreateStaticText(dialogid,4,'Symbol Name',20); 
    		{CreateSymDispCtrlN(dialogid,5,'Arri SkyPanel S60-c',100,100,5,0,2,1,TRUE);}  
    			*** TRIED THE ABOVE AND CreateSymbolDisplayControl, BOTH OF WHICH SHOW ONLY AN ICON, NO MENU
    		CreateEditText(dialogid,5,'Enter symbol here',40); *** THIS IS TEMPORARY UNTIL I CAN FIGURE OUT THE SYMBOL DIALOG
    		CreateStaticText(dialogid,6,'Relative Angle:',20);
    		CreateEditReal(dialogid,7,2,0,10);
    		CreateStaticText(dialogid,8,'Layer:',20);
    		CreateLayerPDMenu(dialogid,9,40);
    		
    
    		SetFirstLayoutItem(dialogid,4);
    		SetRightItem(dialogid,4,5,0,0);
    		SetBelowItem(dialogid,4,6,0,0);
    		SetRightItem(dialogid,6,7,0,0);
    		SetBelowItem(dialogid,6,8,0,0);
    		SetRightItem(dialogid,8,9,0,0);

     

  18. 5 hours ago, JBenghiat said:

    You can use RunTempTool to draw objects during the mouse move event. With vs, you probably can't easily draw a representation of the objects you are moving, but you should be able to draw the bounding box fairly easily. The example in the wiki includes draw commands. https://developer.vectorworks.net/index.php/VS:RunTempTool

     

    Keep in mind that if you're running as a tool, the entire script begins executing at the moment of the first click.

    Thanks for this.  I don't think what I want to do is totally possible (I didn't think it was before I even started), but this temp tool thing could be pretty useful for some other stuff!  One day, I will learn more than you've forgotten about this stuff!

  19. 9 minutes ago, JBenghiat said:

    When in the process are you wanting to draw the preview? You have some limited drawing capacity with event enabled tools, as well as with RunTempTool, but this is generally not something you can do with Vectorscript. 

     

    I would guess with the first click it would choose one point, then it would draw outlines of the new objects in place as the mouse was moved around based on the mouse position, until the mouse is clicked..  I would guess this would work better as a tool than a script.  The end idea is largely based on the "Move By Points" tool, just with different custom options.  

  20. I'm trying to figure out how to code the pre-visualiztion of object placement in a script/tool using Vectorscript.  When you select an object, then use the "Move By Points" tool,  the tool outlines the selected object(s), and dynamically moves them around the workspace as you move the mouse.  I have been trying combinations of GetMouse, Mousedown, TrackObject and such, but can't seem to figure this out.  Is this even possible, or is it something that only an internal Vectorworks tool can do?  Or does it require something like events, which I have never figured out.

  21. 17 hours ago, JBenghiat said:

    @SamIWasYour own object or any object?

    My plugin objects.  I have custom point-object tools I use for racks, cables, optos, network units, consoles, nodes, etc.  In order to make them import/export with FileMaker Pro (where I have an extensive database I use to track every piece), I have a UUID procedure within the tool which assigns a UUID to the object in one of the fields, and as an object name.  The object name will change automatically If duplicated, and the procedure will check to see if the ID and name match, and generate a new ID if they do not.  But I need the UUID procedure to run again after duplication to make the ID unique to each object.  But it won't run unless I change some data.  

     

    HOLY CRAP.  I thought I had tested this before multiple times and it didn't work...but checking "Reset on Move" and "Reset on Rotate" does fix that issue.  Now to go update all my plugins!

    • Like 1
  22. On 7/25/2021 at 7:55 PM, JBenghiat said:

    Note, you need a hex editor to enable an event-based tool. The biggest feature of the event enabled tool is customizing the mode bar, as well as handling multiple clicks easier to work with. Many of the limitations are still there though, for example, the code still doesn't run until after the first click.

     

    I just want code to run when an object is duplicated, so my objectID checker will run.  But every time I see one of those event-enabled scripts, my mind turns into spaghetti.

  23. On 7/21/2021 at 9:07 AM, klinzey said:

    The new parameters are used to store a reference to a resource. They will not be displayed on the OIP.

    For example, the Symbol Definition filed will store the name of a symbol and only a symbol. If you try to put other data in the field if will not store the information.

    When the symbol name is changed in the Resource manager, the filed will be updated so the object can use the new value.

     

    You still need another user interface element to allow the user to select the resource, so these are not simply parameters that you can just drop into the OIP.

     

    The other new options work in a similar manner.

    Thanks, Kevin.  Darn...I was really hoping that it was going to put in a symbol selection menu or a texture selection option.  That would be sweeeeeet.

     

    I guess the only option for those things is to just type the name into a text box, right?

×
×
  • Create New...