Jump to content

JBenghiat

Member
  • Posts

    2,015
  • Joined

  • Last visited

Everything posted by JBenghiat

  1. In theory, all VectorScript constants are available in the vs namespace, so vs.SetupDialogC should work. This event runs for both the ok and cancel case, so in Raymond’s example above, you wouldn’t need to call SaveDialogPos() in two different cases. Vectorworks calls the dialog handler for every user interaction with the dialog, so it can run dozens of times with each dialog session. That means that you will be constantly repositioning the dialog, and if the user drags the dialog to a new position, it will snap back to the coded location.
  2. The parent of PIOHan. You have the test backwards: In preview, the PIO will not have a parent. When placed in the drawing, the parent will be non-nil, and the type will be layer, group, symbol, etc. (If somehow the preview is also non-NIL, check they type). Also be sure to test for duplications and copy/paste. IsNew may be true for both. I think you can get around it with the FirstRegen state (I don't have the constant in front of me) or by setting a hidden field to check if the object is new.
  3. The point object creates a preview for the tool. Check if the parent is NIL.
  4. I’m going to take the opportunity to plug BeamViz, which automatically creates the mask for elliptical beams. https://benghiatlighting.com/software/product/beamviz-6/
  5. GetLine() takes two clicks. Repeat until MouseDown() gathers a third click, which is exactly what you are observing.
  6. My guess is this is just an issue with the feedback string, and you can click ok. That said, I haven’t encrypted this way in years: I always use the batch encryption commands. The advantage is that the plug-in you’re encrypting doesn’t need to be in your plug-in folder, so you can encrypt a copy and not have to worry about locking your original script. I’m fairly sure you can search the forum for an earlier post on the subject
  7. There is not a method to do this, even with the SDK. You have a couple of clip surface commands that could work if your fill is a continuous polyline. An alternative solution would be to draw the insulation using a tile fill or line type that the plug-in scales appropriately. A tile fill would allow you to use separate objects, where you would have to calculate the end miters, while a line type combined with a path-based PIO (as others have mentioned) would make this a fairly easy script.
  8. The short answer is that VS does not have access to the same face selection capabilities that the SDK does. Pat's suggestion would probably work, though it would require a lot of careful duplicating and management of temporary objects.
  9. No, the UUID is core to project sharing, so Vectorworks is dependent on the objects maintaining the UUID generated at creation. You probably need to keep two sets of IDs: The database ID and the VW ID. I believe you can set the VW ID field to be unique but not required, so that new rows won’t duplicate the UUID. FileMaker should allow you to specify a unique index field. Alternatively, you can have a related table that just maps FileMaker record IDs to VW IDs
  10. https://developer.vectorworks.net/index.php/VS:Parametric_State_Notifications#kCreatedReset
  11. It's not quite so precarious — standard namespace rules still apply. When you have a script for objects with parameters, before running the script, Vectorworks will create a constant that uses the name of the parameter prepended with a "P." In python, these are all in the vs namespace, so you can access the parameter length with vs.Plength. Original Vectorscript has everything in the same namespaces, which is where Pat's example comes from. In python, you can have vs.PTS as distinct from PTS. And even in Vectorscript, you would only run into trouble if you also have a parameter named "TS." Note that all the vs.P… variables are constant. You can read a parameter value, but you can not write back to that variable and have it updated the object. For that you would have to use vs.SetRField() PrevObj is a method of vs (that returns a handle, which you can assign to a variable). As such, you would always call the method using parentheses: h = vs.PrevObj() vs.PrevObj refers to the method as an object, and something you would only do if, say, you had a function that took another function as a parameter. That's a fairly advanced coding concept. I suppose that you could get into trouble if you have an object parameter named "revObj," as Vectorworks would try to create a constant "PrevObj" in addition to the existing method. That would lead to either a compilation error or for PrevObj() to be re-defined.
  12. kObjOnInitXProperties runs once per session (Vectorworks open until quit), unless you are running scripts in developer mode, in which case objects are forced to re-initialize on every run. You can use object state events to catch new and duplicated objects. Alternatively, have your export script pull directly from the objects’ Uuid (see Pat’s post above), rather than depending on a record field.
  13. Sorry, one more point of clarification. LNewObj is short for Last New Object. The object creation call, vs.Rect() in the example above, creates the handle. vs.LNewObj() just asks VW to tell us what handle points to the object we just created, it doesn't actually create anything, and you only need to call it if you want to store that object's handle for later (the handle still exists, but if you create another new object, LNewObj() will point to the latest created object).
  14. One other thing, which I know can be confusing, is that some functions that create objects return handles, and some don’t. vs.Rect(), for example, does not return a handle, so you have to call vs.LNewObj() to retrieve the handle. That will always return the handle to the last object created. Other functions like MakePolygon() will return a handle. You just have to consult the function reference to know when you need to use LNewObj
  15. You might have to be more specific, as you have a working code snippet above. You seem to be asking about how to use handles for the duration of your script. In your example, h and j are handles, and you can use them as many times as you like for any function that asks for a handle. You seem to be creating a plug-in object. Every time a plug-in draws, it recreates the objects, so storing any identifier between runs doesn’t really make sense. Variables can’t have a space in the name, so let’s call it Client_1 vs.SetFillBack( Client_1, 255) Client_1 is the variable holding the handle to the rectangle you created. This is not a simple question to answer. Storing names or UUIDs is only necessary if you want to do things like link two plug-in objects together. You would have to describe exactly what your are trying to do. If you’re just trying to refer to objects within the same script none of this is necessary. If you did want to retrieve the UUID of the rectangle and store it to a database field, you would call: rectangleUUID = vs.GetObjectUuid(Client_1) Here’s a simple script using a handle #get the handle of the first selected drawing object and store it to a variable, h h = vs.FSActLayer() #Move the object 6 units to the right vs.HMove( h, 6, 0 ) #Change the object’s line color vs.SetPenFore( h, 42 ) For the duration of the script, h will point to that selected object until you either delete the object or assign h to another object via a function that returns a handle. If you are confused about the concept of variables and scope in general, you can try starting here: https://www.w3schools.com/python/python_scope.asp
  16. @FranAJA Again, I think you are over-thinking things. Handles are how Vectorworks tracks every element the drawing, and as such, every object already has a handle. The handle gets assigned to each object read from the saved file into memory and to every new object you create. You never have to "give" an object a handle -- you can only query Vectorworks to tell you the handle for the object you want. I think this is what is confusing you. The handle is the memory address where you can find the object. All the functions that return a handle aren't creating the handle, they are helping you find a handle that already exists. Functions that require a handle need to know where to find that object in memory. vs.LNewObj() is the equivalent of "What is the memory address of the handle I just created" Even though each object has a unique handle, because it is a memory address, you would never want to store the value of the handle anywhere, as it will change every time you load the file. ### Here's my analogy. Imagine that the Vectorworks drawing is a crowded bakery, and the handle is the number each customer takes as they enter. The numbers are all unique, but even if a group of regular customers returns to the bakery every day, their numbers will be different. We have a lot of ways we can find out which customer has each number. We can ask the first person or last person in line what number they have. Asking the last person is the equivalent to vs.LNewObj(). We can point at a customer and ask them what their ticket number is. This is similar to vs.FSActLayer(), which gives us the first selected object on the active layer. If we ask each customer to also put their name on a list as they enter, we can call out their name and ask their number. This is the equivalent of vs.GetObject(). Of course, if the customer doesn't add their name, we can't use the list of names to find their ticket number. Objects in Vectorworks can, but are not required to have names. We can also require each customer scan their government ID as they take a number, and use that list to ask the group what ticket number matches an ID. This is the equivalent of vs.GetObjectByUuid(). Another thing we can do is ask all the customers with red shirts what their ticket numbers are. This would be the equivalent of criteria functions that return handles. Finally, if a customer leaves the bakery without being served, and gives their number to a new customer walking in, that ticket number now refers to a new customer. This is equivalent to deleting an object and creating a new one, and an example of why storing handles as data is never a good idea. HTH
  17. You may be over thinking it. The handle is just an object identifier you pass to functions — it doesn’t get called. Your issue is that VW uses 16 bit color values: https://developer.vectorworks.net/index.php/VS:SetFillFore, so 256 will be a negligible tint.
  18. Vectorworks loads the entire drawing into memory, and a handle is essentially a variable that can hold the location of each object in memory. That means each handle points to a unique object, but it is not a persistent object identifier — every time you open a file, objects load into different memory blocks, and memory might also get re-used if you delete an object. An empty handle means it is not currently holding the memory location of any object. Once you have a handle to an object, out can think of it as an alias to the object (hey compiler, look here and do x with this object). You can get handles to objects by creating new objects or by traversing the document’s structure, which is organized in a tree. In addition, Vectorworks also keeps an index of handles for all objects, so you can retrieve a handle via object name or UUID.
  19. The best solution depends a lot on exactly what you are trying to accomplish, and your current knowledge of Python and/or Javascript. This isn't the sort of thing where a 10-line example will give you what you need -- if you're new to coding, you may want to contract for this work on spec. One caveat -- you aren't going to be able to have a live connection between VW and GS with Python. You may be able to get some live sync by using an ODBC connection in VW and an Apps Script to build the sheet. You should also be able to build a live connection via the SDK. Possibly the most straight-forwards method is to write data to an Excel sheet on Google Drive, and then (if you don't want to manually import) create an Apps Script to import the Excel workbook into Sheets. VS has commands for working with Excel files here: https://developer.vectorworks.net/index.php/VS:Function_Reference#Excel. You can also find third party Excel libraries for Python. A tutorial for importing via Apps Scripts is here: https://spreadsheet.dev/automatically-convert-excel-spreadsheets-to-google-sheets-using-apps-script#use-apps-script-to-convert-excel-xls-xlsx-to-google-sheets Similarly, you can use Python's csv library to export your data and read via App Script. If importing to Sheets seems daunting, you can use an intermediary service like Zapier, which can monitor a cloud drive or web hook and create your Excel data: https://zapier.com If you want to create your Sheet directly from Vectorworks's Vectorworks, start with these commands to read worksheet data and formatting: https://developer.vectorworks.net/index.php/VS:Function_Reference#Worksheets Google offers a Python API for working with worksheets. You can find an overview and examples here: https://developers.google.com/sheets/api/guides/values#python Or a variant of that would be to use Python to post the data to the Sheet's web app, and process with Apps Scripts. https://trevorfox.com/2017/01/google-apps-script-doget-and-dopost-tutorial-6-web-app-examples/
  20. If you’re looking to manually move data, you can go to the file menu in the worksheet window, and export as csv or Excel, and import to Sheets. If you want to use python to do this programmatically, it is definitely possible — VectorScript can read your worksheet data, and you can either use Google’s API and an OAuth key to write directly to a Sheet, or post the data to the sheet and process with an Apps Script.
  21. What do you mean by “activate”? Are you looking to use the Google API to read or write to Sheets? On the Vectorworks side, do you want to pull from worksheets or directly from objects?
  22. Here's some additional selectors: ovRenderStyleQualityGeometry = 1261; //Short ovRenderStyleQualityAntiAliasing = 1262; //Short ovRenderStyleQualityIndirectLighting = 1263; //Short ovRenderStyleQualitySoftShadows = 1264; //Short ovRenderStyleQualityBlurriness = 1265; //Short ovRenderStyleQualityEnvLighting = 1266; //Short ovRenderStyleMaxReflections = 1267; //Short ovRenderStyleApplyLighting = 1268; //Boolean ovRenderStyleIndirectLighting = 1269; //Long ovRenderStyleHDRIRefNumber = 1270; //Long ovRenderStyleHDRIOption = 1271; //Long ovRenderStyleHasHDRIOption = 1272; //Boolean ovRenderStyleEnableAmbient = 1273; //Boolean ovRenderStyleAmbientBrightness = 1274; //Real ovRenderStyleAmbientColorR = 1275; //Real ovRenderStyleAmbientColorG = 1276; //Real ovRenderStyleAmbientColorB = 1277; //Real ovRenderStyleEmitterBrightness = 1278; //Long ovRenderStyleWhiteColorTemp = 1279; //Long ovRenderStyleApplyBackground = 1280; //Boolean There seems to be two selectors, one that's ovRenderStyleQualityIndirectLighting and one called ovRenderStyleIndirectLighting. You can see if the former will work to set the option. You may also have to set ovRenderStyleApplyLighting to true, or instead/additionally use ovRenderStyleMaxReflections to set the number of reflections.
  23. PTipo will give you the selected value as a string (‘Custom’, ‘10’, ‘20’, etc. ). You then have to use a series of if/then statements to control your code. In VS, there is no way to retrieve the index of the radio button.
  24. Here is the function Pat was referring to. https://developer.vectorworks.net/index.php/VS:Get3DCntr Modify collect() to pass the handle to Get3DCntr, and add the coordinates to the list as a tupple.
  25. Unless you need a specially formatted text file, you can also make a worksheet that displays this data, and then export the worksheet.
×
×
  • Create New...