Jump to content

SamIWas

Member
  • Posts

    296
  • Joined

  • Last visited

Posts posted by SamIWas

  1. 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.

  2. 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.

  3. 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;

     

  4. 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!

     

     

  5. 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.

  6. 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);

     

  7. 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!

  8. 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.  

  9. 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.

  10. 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
  11. 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.

  12. 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?

  13. I've been making custom scripts and plugins for quite some time.  But, I just noticed, I guess after a 2021 upgrade, that there are new options for script parameters (I assume these didn't exist .  I got excited to see material and texture options, and a symbol definition.  I was hoping these would allow me user-input of textures and symbols.  But, they don't appear to do that.

     

    Can anyone explain how these are used, or if they don't actually do anything with point plug-ins unless they're set up a certain way?

     

    image.png.edc2fb2436afe7320077b9cf0d815f57.png

  14. 1 hour ago, Jesse Cogswell said:

    @SamIWas ,

    @line-weight mentioned in the original post that they have been using the eyedropper tool to do this, but it becomes very tedious if you have a large number of viewports spread across multiple sheet layers, the tool I wrote and posted above allows you to do it all in one go, and has the ability to force the viewports to run an update as well.

     

    Sigh...that's what happens when I don't finish reading the entire post and move on to the responses....🤔

     

  15. On 10/21/2020 at 7:13 PM, line-weight said:

     

    Yes indeed ... although there is also the possibility that an investment of time doing something moderately engaging, to write a script say, is still worth it, if it avoids a smaller amount of time doing something incredibly tedious/frustrating.

     

    Note that the eyedropper tool works on viewports with layer and class settings and is pretty immediate.

  16. On 10/26/2020 at 1:26 PM, Pat Stanford said:

    The Message command "stopped working" a few versions ago in that it does not operate during a Vectorscript, but only at the end of the script. At least that is my memory.

     

    You can either use AlrtDialog, and require the user to hit enter to proceed. (this is my go to for debugging) Or you can try AlertInform and set it to be a minor alert. The problem with that is the second time you call AlertInform it ignores the Minor and pops up a dialog box instead of just putting the information into the message bar.

     

    If you really feel you need a progress indicator you might be better off in Python and use Python objects instead of VW objects.  +1 to @JBenghiat 😉

     

    So THAT'S why so many of my scripts don't report what they used to.

  17. 3 hours ago, Pat Stanford said:

    When you Ungroup a PDF you typically end up with 3 items. A bitmap of the PDF on top. A white rectangle (we think it represents the paper). And finally at the bottom a Group containing all of the vector linework and text that VW can extract from the file.

     

    It sounds like you had ungrouped the PDF and deleted the bitmap but not the rest.

     

    Glad you found the problem.

    Yeah...I've done the deal with PDFs for many years, ungrouping then dealing with the resultant parts.  For some reason, I just missed that they were there since they were hidden and weren't selecting.  

  18. 11 minutes ago, Pat Stanford said:

    How complicated is your drawing? You might try exporting back on version to a VW file and then updating that back to your current version.

     

    Is there any specific action that causes the lines to show?

     

    Have you tried to Purge unused objects?

     

    I just opened this back up to say that I found the issue.  The lines were there, but were covered with a white rectangle, thus not appearing when I showed everything.  I was sure I had deleted them, but apparently I had not.

  19. I had imported a pdf, which I ungrouped to get normal lines.  It brought in hundreds of thousands of lines, which of course bogged down the machine.  I deleted all of it.  Weeks later, I'm working on the drawing, and periodically when zooming or performing a move command, these phantom lines reappear for a few seconds before going away.  Being that it's 100,000 of them, it causes a long pause on my MacBook Pro.  I have turned on every class and layer, and the lines are not actually in the drawing.  They are just phantoms showing up randomly.  Any idea how to get rid of these...it's absolutely draining my workflow speed.  I'm starting to think I will have to manually copy each and every existing thing to a new document...

  20. 16 hours ago, Pat Stanford said:

    It actually is not that bad. There are a number of ways to do it with some fairly simple loops.

     

    Probably the easiest would be a ForEachObject using a Criteria of Selected is True and PON = 'Door'. PON stands for Plug-in Object Name.

     

    Code fragment not tested:

    
    Procedure(Test);
    
    Procedure Execute(Hd1:Handle);
    Begin
      SetClass(Hd1,'MyClass');
    End;
    
    Begin
      ForEachObject(Execute, (((Sel=True) & (PON='Door'))));
    End
    
    Run(Test)

     

     

     

    Holy crap, man...that worked!  This is going to make updating old files, and inserting new doors and windows, so much faster!

  21. 37 minutes ago, Pat Stanford said:

    It actually is not that bad. There are a number of ways to do it with some fairly simple loops.

     

    Probably the easiest would be a ForEachObject using a Criteria of Selected is True and PON = 'Door'. PON stands for Plug-in Object Name.

     

    Code fragment not tested:

    
    Procedure(Test);
    
    Procedure Execute(Hd1:Handle);
    Begin
      SetClass(Hd1,'MyClass');
    End;
    
    Begin
      ForEachObject(Execute, (((Sel=True) & (PON='Door'))));
    End
    
    Run(Test)

     

     

    Thanks Pat!  I'll try this tomorrow and see how it goes.

  22. 3 hours ago, MullinRJ said:

    Using: Message(GetTypeN(FSActLayer));

     

    If I select a free standing Door I get type 86 (Plug-In object).

     

    If I select a a Door in a Wall I get type 68 (Wall object).

     

    To see the Door on a test wall I have in an open document, I needed to use:

    Message(GetTypeN(NextObj(NextObj(NextObj(NextObj(NextObj(NextObj(NextObj(FIn3D(FSActLayer))))))))));

     

    As you can see, the door object is deep inside the Wall object. The number of objects in front of it are not exact, and are determined by the wall's construction. You should use a loop to look for the Door, or possibly try ForEachObjectAtPoint(). There may be a more direct way to get to the Door-in-Wall that someone else can point to. I've just done a cursory quick dive at this. 

     

    Again, make sure your handle is pointing to a Door object before trying to access its record.

     

    HTH,

    Raymond

     

    Holy schniekies.  So, it looks like selecting a bunch of doors throughout a document and trying to change records in this way wouldn't work very well.  

     

    What I was trying to do was create a script that would assign my default class scheme to doors that I pull in from older drawings.  

  23. With the lighting device, I can just use SetRField and GetRField to get and set info for the lighting device.  With door, this doesn't seem to work.  As a test, I used GetRField(h,'Door','2DLeafClass') and GetRField(h,'Door','2D Leaf Class').  but neither works.  Is there different way to get and set door info via script?

     

    EDIT:  I have found that it works when the door is not in a  wall.  But, once the door is placed in a wall, I can no longer get the script to pull info from it.  Surely there is a way.

  24. 1 hour ago, rDesign said:


    I believe that FileMaker can import from & export to Excel files, so presumably you could use this new 2021 Excel file functionality as the means to transfer data / records between Vw <—> FileMaker, without needing the MS Excel application itself. Just a hunch.

     

    Yeah, I already do that via text files.  It's just an extra step in the process.   I know that a direct, immediate, and automatically updating connection is possible with Filemaker via ODBC.  I've gotten it working briefly on small projects, but it is mind bogglingly difficult.  I'm hoping for VW and FM to work together to make a solution with easy, automatic connection between the two.  FM Is so powerful when it comes to tracking and reporting data.

    • Like 3
×
×
  • Create New...