Jump to content

Martin Crawford

  • Content Count

  • Joined

  • Last visited

Everything posted by Martin Crawford

  1. My code is super simple. When the routine completes, it always up on the Design Layer. layerName = vs.GetLName(vs.ActLayer()) vs.ForEachObject( vs.ResetObject, "PON='Create Data'" ) vs.ForEachObject( vs.ResetObject, "PON='Create Circuit'" ) vs.ForEachObject( vs.ResetObject, "PON='Create Notes'" ) vs.ForEachObject( vs.ResetObject, "PON='Create Scehdule'" ) vs.Layer(layerName) I do change layers inside of Create Data and Create Circuit and it looks like whichever of those two runs last determines what layer it is on. Create Note and Create Schedule are on Sheet Layers and neither change layers. What does not make sense is why my Vs.Layer at the end does not change back to the sheet layer. Martin
  2. Is there a way to reset some custom plug-ins, and when done return to the layer that called the refresh? I have two custom plug-in, the first is a "data circuit", the second is a "data note" with info from the data circuit. From a Sheet layer I want to use a menu command to run "Refresh Notes", that will refresh the "data circuit", then refresh the "data note" and when all done I would like to stay on the Sheet Layer. Currently when I do the refresh on the "data circuit" it changes to the Design layer and so far nothing I have done can get it back to the Sheet Layer. I suspect is has to do with the ForEachObject not working like I think it should. Any thoughts on how to move forward? Thanks Martin
  3. Currently I do something similar to what you descibe, where you select everything from design layer and it will create the viewports on the raster layer. It works, however any changes can mean deleting the raster and starting over, or worse a change can occur in the layout and not get caught in raster. The new guys make this mistake more times than I would like. Why is a good question. We create our LED displays at actual size and according to the physical layout. We also create a sheet that shows the raster and how the pixels need to be within the raster. This is often very different from the physical layout. On a recent large project the raster had no resemblance to actual layout. Our goal was to reduce the number of raster and cram as much into one raster as possible. It was a game of Tetris coming up with the optimal layout, however the team did miss one small section of the physical display that caused a last minute scramble to resolve. We could have as many as 30-40 different viewport to create the raster. The thought was if I could use a custom object that creates the Viewport, then I can place one object on sheet layer, then copy and paste and change the parameters to get what I need. And if a change occurs (add a panel, change a panel, change the size of the panel), it would automatically be reflected in the raster layout. It also allow me to enforce some rules on not what can be split in the raster and what cannot. A second benefit to have everything in the custom object is it is easier to run an error check to make sure all sections of the display are mapped in the raster. On small systems, it's not an issue, on the bigger system that span multiple floors in a high rise with multiple rack room, it can be easy to miss a display and not have it appear on any raster. From reading the website, a viewport can be in a group, as long as the group is on layer. When I try to create a VP in code, it returns nil as the handle and create the Viewport on the Sheet Layer. I'm not sure of a good way to do the error checking other than a lot of ugly code to see what panels are in what viewport and what viewport is in what raster. Doable, but a lot of code.
  4. My goal is not select visually, but use the vs.SelectObj(searchCriteria) to select everything. Image a LED panel that I have assigned a display number, processor and port id. Using the SelectObj I can select everything I need, draw a rectangle, and change the rectangle parent to the Design Layer. This this part works nicely. My hope was I could then create a ViewPort, assign the VPCrop and have a Custom Object on the sheet layer that I could change the parameters and get an updated viewport. I don't think this is possible as the viewport can only have a parent of a layer (or nested layer) and can't be inside my custom object. From VectorWorks : "Creates a viewport object. The specified parent handle may only be a layer or a group contained within a layer, nested or otherwise." It's not completely tragic as I will rework the code to run from the menu. The Custom Object would have been a cleaner solution, but the menu option will work. Thanks for all the Help on this!!
  5. I just had a thought..... If I draw the correct size box while on the Sheet Layer, then change it's parent to the Design layer, then the box shows up in the correct Design Layer & in the correct position. I'm not think this may actually work, I will report back if I get it working.
  6. I am currently doing option 2, where I select an object(s), draw a rectangle, create the viewport and move it to a Sheet Layer. This works great as a menu command. I was trying to see if there is a way to convert this to a tool command. My thought was while on the Sheet Layer, you use a tool command (Create ViewPort) that has a few parameters that control what is being displayed. Then when changing the parameters I could reselect and redraw the viewport. This would make it a bit faster to create the sheets layers and eliminate the bouncing between Design and Sheet Layers that we currently doing. The part that I think is stopping me is having the Custom Object one a sheet layer draw the rectangle that will be used as the crop object as that needs to be on the Design Layer. I'm not clear on where the crop objects lives after it is part of the viewport. Is it part of the viewport or is it an object on the Design Layer. Martin
  7. i am trying to create a viewport object that will be on Sheet layer that draws the bounding box for a viewport. The main object would have a few parameters that turn select objects and draws the box that will become the viewport. i don't mind event driven (i think) as i have a few other tools that should be event driven.
  8. Can you have a Custom Tool Object that has items on multiple layers? I would like to have a viewport object on the Sheet Layer that draws the bounding box on a Design Layer. I'm thinking this is not possible?? Thanks
  9. I have two scripts, main.py and utility.py It appears that utility.py is being cached and any change I make is not seen by main.py unless I restart vw. Is this normal, and perhaps more important, how do I work around this. Can I simply delete the files in the __pychche__ folder any time a change is made? Thanks Martin
  10. I think my core issue is the my Utility.ps was being cached and any changes I made were not being picked up. I'm not sure if this is the best way, however for some of my functions used in the Utility.py I am importing what I need inside the function. For example, to get the ConvertToFeet function to see the Fraction command, I did the following: #***************************************************** # Convert to Feet & Inches & Fractions #***************************************************** def ConvertToFeet(decimalInch): from fractions import Fraction feet = (int((decimalInch / 12))) inch1 = ((decimalInch / 12) - feet) inch2 = (inch1 * 12) inch3 = (int(inch2)) frac1 = inch2 - inch3 frac2 = int(round(frac1 * 16,0)) / 16 frac3 = Fraction(frac2).limit_denominator(16) if frac2 == 0: feetString = str(feet) + "' " + str(inch3) + '"' else: feetString = str(feet) + "' " + str(inch3) + " " + str(frac3) + '"' return(feetString) I will post a different topic on how the cache works and how to work around not having to start VW every time I make a change. Thanks
  11. Yes, that is what I have done. I have a main file called CreateData.py and a Utility.py. Utility.py does not allow reference to any vs.* commands. Martin
  12. I think I was pointing to the wrong folder, so I can not import the module, however inside the Utility.py module, I am getting an error on all the vs. commands. I tried putting a import vs at the top of the Utility.py however this does not work. What do I do to get the vs command usable in the Utility.py script. Thanks
  13. I have read many of the forum posts on importing, however I think I'm more confused that I was. I have a bunch of standalone functions that I use in multiple scripts. Nothing fancy, just basic utility functions. I have taken them all and placed them into a separate python file and I would like to import these functions into my scripts. I thought it would be as simple as making sure the path is in the script path and then doing in import. My functions are in a file called Utilities.py and I'm doing a import Utilities When the code runs, I get a No Module Name. Is there a way to include the path into what is being imported, that seems like it would be cleanest option. Thanks
  14. @ Pat I will check the strings and make sure they are good, however I do know the routine is being triggered as it will visible update the screen. The real challenge is after the reset, I can no longer select the Create Display object. I did discover that if I select a different class, turn the Panel class off, then back on, the reselect the Panel class, then I can select the Create Display.
  15. I am running the refresh as the very last line of code. RefreshPanels(panelSpecificationID,UUID) Both panelSpecification and the UUID are parameters to the Create Specifications. Nice tip on passing to ForEachObject, it makes sense, just never thought about it.
  16. I have a strange thing occurring. I have several custom objects that I use and I am having an issue with the reset code on one of them. Here is a list of custom objects Panel Specification Create Panel Create Data Create Circuit Create Display All four of the Create objects refer back to the Panel Specification. In side of Panel Specification I have code to reset the four Create objects, so if any of the Specifications change, all related objects are update. This all works quite nicely. The strange thing that is occurring, is after Panel Specification runs and all the updates are done, I am unable to select the Create Display object. I can select all the others, just not Create Display. The only way I can get it selectable again is by using the Custom Selection tool, then make a change to one of the Create Display parameters. Does this make sense, and is there a workaround? Here is the code for doing the reset. It works, except for not being able to select the Create Display object when all done. #***************************************************** def RefreshPanels(PanelSpecificationID,UUID): #***************************************************** def RefreshPanelsDetails(h): vs.ResetObject(h) pass searchCriteria = "(INOBJECT & INVIEWPORT & (PON='Create Panel') & ('Create Panel'.'PanelSpecificationID'='" + PanelSpecificationID + "'))" vs.ForEachObject( RefreshPanelsDetails, searchCriteria ) searchCriteria = "(INOBJECT & INVIEWPORT & (PON='Create Display') & ('Create Display'.'PanelSpecificationID'='" + PanelSpecificationID + "'))" vs.ForEachObject( RefreshPanelsDetails, searchCriteria ) searchCriteria = ("((PON='Create Circuit') & ('Create Circuit'.'UniqueID'='" + UUID + "'))") vs.ForEachObject( RefreshPanelsDetails, searchCriteria ) searchCriteria = ("((PON='Create Circuit') & ('Create Data'.'UniqueID'='" + UUID + "'))") vs.ForEachObject( RefreshPanelsDetails, searchCriteria ) pass
  17. So I got it work correctly by NOT using any of the code from the documentation and reworking an existing script that was working. Now I have a different question, can I have two dropdown and have the first control the content of the second. For example, the first is supplier, the second is part numbers. If the supplier changes, the part numbers would update with only parts to the correct supplier. I can setup the arrays when I read the csv file, the question is how would I clear the contents of the second dropdown (part numbers) when the first changes. Thanks
  18. Sorry, the code is a direct copy from the website. #*************************************************************************** import vs import math import csv def execute(): #***************************************************** #Functions #***************************************************** #***************************************************** def AddChoiceSample(): #***************************************************** # control IDs global kCreatePullDownMenu global kCreatePullDownMenuGroupBox global kCreateListBox global kCreateListBoxN global kCreatePushButton global SetupDialogC kCreatePullDownMenu = 33 kCreatePullDownMenuGroupBox = 34 kCreateListBox = 29 kCreateListBoxN = 30 kCreatePushButton = 100 SetupDialogC = 12255 #***************************************************** def Dialog_Handler(item, data): #***************************************************** if (item == SetupDialogC): vs.AddChoice( dialog, kCreatePullDownMenu, 'kCreatePullDownMenu choice', 0 ) vs.AddChoice( dialog, kCreatePullDownMenuGroupBox, 'kCreatePullDownMenuGroupBox choice', 0 ) vs.AddChoice( dialog, kCreateListBox, 'kCreateListBox choice', 0 ) vs.AddChoice( dialog, kCreateListBoxN, 'kCreateListBoxN choice', 0 ) #***************************************************** def CreateMyDialog(): #***************************************************** global dialog dialog = vs.CreateLayout( 'Select Panel to Import', 1, 'OK', 'Cancel' ) #{create controls} vs.CreatePullDownMenu( dialog, kCreatePullDownMenu, 24 ) vs.CreatePullDownMenuGroupBox( dialog, kCreatePullDownMenuGroupBox, 24, 'pull down menu', 1 ) vs.CreatePushButton( dialog, kCreatePushButton, 'push button' ) vs.SetFirstGroupItem( dialog, kCreatePullDownMenuGroupBox, kCreatePushButton ) vs.CreateListBox( dialog, kCreateListBox, 24, 4 ) vs.CreateListBoxN( dialog, kCreateListBoxN, 24, 4, 1 ) #{set relations} vs.SetFirstLayoutItem( dialog, kCreatePullDownMenu ) vs.SetBelowItem( dialog, kCreatePullDownMenu, kCreatePullDownMenuGroupBox, 0, 0 ) vs.SetBelowItem( dialog, kCreatePullDownMenuGroupBox, kCreateListBox, 0, 0 ) vs.SetBelowItem( dialog, kCreateListBox, kCreateListBoxN, 0, 0 ) if vs.RunLayoutDialog( dialog, Dialog_Handler ) == 1: pass #***************************************************** # Main Code #***************************************************** kCreatePullDownMenu = 0 kCreatePullDownMenuGroupBox = 0 kCreateListBox = 0 kCreateListBoxN = 0 kCreatePushButton = 0 SetupDialogC = 0 dialog = 0 AddChoiceSample() CreateMyDialog() #***************************************************** # End of Code #*****************************************************
  19. Hi I am trying to read a csv file and create a drop down menu item. I have the reading of csv working, however I can't seem to get the drop down to work. I have started with the sample code from the Vectorworks Developer, however when I run the code I don't get any options in the drop down. Also, I don't know that I really understand what the code is doing, can someone shed so light on how this should be working. Here is the code I working with. https://developer.vectorworks.net/index.php/VS:AddChoice When I run the code I get a empty drop down. Thanks
  20. Thanks, I didn't know the three dot trick. While this works, I am hoping to incorporate this is into a script that will enforce the precision standard and add to an existing script that update worksheets, custom PIO's, etc. Is there a way to get the field name of the parameter I am looking to change.
  21. Is there a way to script changing all the precision values in a drawing to something. I have drawings that are all done in mm and sometime the team will use 1/4" as the precision (secondary) and sometimes 1/8" . I would like to force everything to 1/16" I can set the criteria for finding all dimensions, I'm just not sure what the field value would be. Thanks


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...