Jump to content

JBenghiat

Member
  • Posts

    2,004
  • Joined

  • Last visited

Everything posted by JBenghiat

  1. You are correct— encryption substitutes a token for all the variable and constant names, so the value passed to the VSValue isn’t valid. The string repository commands (RepStr) will work, however, both for passing data between vs and python as well as for preserving data between script runs.
  2. A number of potential issues, and some confusion about your description. Screen plane objects don’t appear in 3D views. The only place where you will currently find screen plane objects is in hybrid symbols and PIOs, and because you only see the 2D component in top/plan, you aren’t really aware of the screen plane. If you are seeing a planar object in a 3D view, it’s in the layer plane or another 3D plane. CreateTaperedExtrude appears to be essentially deprecated. Use CreatTaperedExtrd2. Just going by memory, but I believe that when you create an extrude, the profile becomes part of the extrude without creating a duplicate. I believe what you are seeing is the object not having a 2D component, so you are only seeing the 3D in both views. SetPlanarRef only works on 2D objects ( the 3D object exists in non-planar space). Because the extrude call returns a handle, it’s possible that LNewObj() still refers to the oval. In the PIO code, all planar objects get created in the screen plane, so an extrude will give the object depth from the current view. Therefore, you DO need to set the planar ref (usually the layer plane) for all planar objects BEFORE extruding. HTH
  3. Just to clarify @FranAJA‘s remarks, storing a handle into a variable is fine, but you should not store a handle into a parameter or any other kind of persistent storage. These were the warnings about handles at the top of the thread. A handle is nothing more than the location of a drawing object in memory. You can only reliably depend on that block of memory referring to the object you want for the duration of the script, and as long as the script doesn’t delete or otherwise invalidate the object. If you need to store a list of objects for later use, use their UUID or assign name, which can then be used to retrieve the handle.
  4. You might have to be more specific about which issues you’re referring to. Python isn’t able to pause and wait for input the way VW does — this is due to how the language works, and you have to construct your script with callbacks of you want to handle user interaction. This can’t be changed by running vs within python: you still have the same issue with Python being non-blocking. Both VS and python tool scripts don’t execute until the first click, and there’s no way around that. Track object and temp tool work best as menus. There’s also a bug that appeared in 2023 that would cause temp tool to crash. I’m not sure if that has been fixed yet — but it’s a regression, so it should be high on the list.
  5. @Andrey Shulyak Those are two different things. The Clip Cube is the 3D cube that will create a red cut plane with intersecting solids. Cropped Perspective is the legacy perspective view that has four black corners defining the frame. Either way, your solution will use object or program variable constants. Best to stay away from anything NNA_internal unless you’ve been explicitly given a code snippet from an engineer.
  6. @michaelk does this also work in python? In VS, numerical constants can utilize both standard and metric unit marks, and the conversion is automatically handled. Last I checked, this didn’t work in Python, but that was a while ago. @Jayme McColgan a general coding best practice is to avoid “magic numbers,” basically un-named constants. In practice, this can become impractical if you are creating poly lines via script, but ind your case you do have a bunch of repetition, so, for example: kLeftBound = -7.34 would reduce the number of conversions, as well as make maintenance and readability easier. Raymonds approach is fantastic for a quick fix, but I would do the opposite: retrieve the UPI (Units Per Inch) and then multiply any constants defined in inches by the UPI. If you’re specifying dimensions in mm, define UPMM by dividing the returned preference by 2.54
  7. Assuming you have a list of old classes that map to new classes, and you have a means to traverse them (if you switch to python, you can use a dict). Classes have handles, so for each old name, see if GetObject returns a handle. If the handle exists but does not refer to a class, you need to either generate a warning or handle the name conflict in some way. Otherwise continue: Try to get a handle for the new class name. If it does not exist, simply rename the old class to the new class. If the new class name exists but does not refer to a class, handle the conflict by either alerting the user or modifying the new class name until it is valid Once you have a valid name for the new class, do a ForEachObject with deep traversal and change any objects that use the old class to use the new class.
  8. What exactly do you mean by clipbox? The clip cube, the cropped perspective frame, or something else?
  9. @michaelk has the answer. Note that there is a bug where not all text attributes get saved — I know alignment does not, and possibly line spacing, so you would have to manually code those (either set to a constant value or store to a parameter) @MullinRJ what you’re finding are the options to display the text style menu in the OIP. I believe that you also need object variable 800 on for style assignment to work automatically, otherwise you need to get the object’s text style and apply it to each text block.
  10. Unless this is part of a larger process, you can also export csv from the worksheet’s file menu
  11. CallTool isn't going to work for you. The tool will want to collect two points, then (I recommend) use vectors to calculate the length and rotation. Use the CreateCustomObject commands to place the pipe and/or create a Hanging Position. The universal name for the Hanging Position is "Light Position Obj". Use SetRField to set parameters. I know there's been posts on the forum about DebugListView, which can help you find universal names and hidden parameters. You can also construct a sample Hanging Position and examine the output of Export VectorScript. The pipe is path-based, so either call CreateCutomObjectPath, or set the path group after creating the object (the path should be a polyline). Any geometry in the Hanging Position needs to be inserted in its profile group. The trickiest thing is translating been the plug-in's internal coordinates and the coordinates of the overall world.
  12. @SamIWas You raise several questions here. Any object can be turned into a Hanging Position, and this can be accomplished with VectorScript. This would be the same as selecting the object, then choosing the Create Hanging Position command. In order to modify the geometry, you would have to edit the Hanging Position’s profile group. If you are asking if any object can be turned into a Rigging Object so that it directly interacts with Lighting Devices and loads, but still has options available in the OIP (without editing the profile group), then no. Rigging Objects need to be able to “answer” a certain set of questions that Vectorworks “asks” of them, and this is only possible via the SDK. In terms of snapping to the I-beam, this also wouldn’t be possible without the SDK. You can, however, place a Lighting Pipe at the bottom of the beam, and turn off the “draw pipe” option. This will give you a snappable line with the possibility of tick marks. You can definitely place a Lighting Pipe inside another PIO, but I’m not sure if it will still be detected as a rigging object. What you envision is definitely possible with the SDK. In VS, you can design a custom tool that draws a beam, places a Lighting Pipe for snapping, and wraps them in a Hanging Position.
  13. I think that menu and tool parameters haven’t worked for some time. Instead, use Get/SetSetting, a hidden record (GetObject(RecordName) gives you a handle to the record definition), or the string repository (RepStr commands)
  14. Plug-in objects have a record attached to them to hold plug-in parameters, but can also have data records attached to them, of which EntEquipUniversal is one. The plug-in record is not guaranteed to be the first record attached. Your best method depends on how you are filtering objects. If you are using ForEachObject, you can use the selected 'PON' (Plugin Object Name) to match a plug-in object by its universal name. You can also iterate through attached records, though I prefer using Eval and the PON criteria.
  15. 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.
  16. 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.
  17. The point object creates a preview for the tool. Check if the parent is NIL.
  18. 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/
  19. GetLine() takes two clicks. Repeat until MouseDown() gathers a third click, which is exactly what you are observing.
  20. 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
  21. 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.
  22. 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.
  23. 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
  24. https://developer.vectorworks.net/index.php/VS:Parametric_State_Notifications#kCreatedReset
  25. 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.
×
×
  • Create New...