Jump to content


  • Posts

  • Joined

  • Last visited


12 Good

Personal Information

  • Occupation
    Entertainment Designer
  • Location
    United States

Recent Profile Visitors

981 profile views
  1. Here's the PIO file. I think this is all you need? I haven't really gotten around to figuring out portability yet. 😆 PathExample.vso
  2. A fair point to explore- that was the only way I could figure out how to make the path a visible element in the drawing when I was getting started with my scripting and I've just continued to do it as it was working, but it does seem like there has to be a better way of approaching this that I'm missing- perhaps by some preference setting I haven't found yet? I never dug any deeper into that once the duplication solved the initial hurdle. That said, getting rid of the duplication doesn't help the situation and the initial path object is still grabbed by the symbol creation so it's just one less Handle variable is NIL error in the initial output until the symbol is created.
  3. Thanks Pat. Here's the simplified code for reference. This would be part of a 2D path PIO with Events enabled. import vs spacingBetween = 9 bUseSymbol = True markerSymbol = 'Direction Marker' (BOOL, pioName, pioHandle, pioRecordHandle, pioWall) = vs.GetCustomObjectInfo() # ---------------------------------------------------------------------------------------------------------------------- def positionMarkerSymbolResource(): if vs.GetObject(markerSymbol) == 0: # Check if symbol already exits, create symbol if not vs.BeginSym(markerSymbol) positionMarker((0, 0)) vs.EndSym() def positionMarker(pt, rotation=0): markerWidth = 3 markerGroup = vs.BeginGroupN(None) vs.ArcByCenter(pt[0], pt[1], markerWidth/2, 0, 360) # Draw Circle component vs.BeginPoly() # Draw Triangle component vs.MoveTo((pt[0] - markerWidth / 2, pt[1])) vs.LineTo((pt[0] + markerWidth / 2, pt[1])) vs.LineTo((pt[0], pt[1] + markerWidth / 2)) vs.EndPoly() vs.SetPolyClosed(vs.LNewObj(), True) # Close Triangle vs.SetFillBack(vs.LNewObj(), (0, 0, 65535)) # Set Triangle Color vs.EndGroup() vs.HRotate(markerGroup, pt, rotation) # Rotate Marker Group return markerGroup def main(): pathHandle = vs.HDuplicate(vs.GetCustomObjectPath(pioHandle), 0, 0) vs.SetFPat(pathHandle, 0) # No Fill pathLength = vs.HLength(pathHandle) # Length of Path ptCount = int(pathLength // spacingBetween) + 1 # Max Count by spacing for i in range(ptCount): distance = spacingBetween * i #Distance per step (b, pt, tangent) = vs.PointAlongPoly(pathHandle, distance) rotation = vs.Vec2Ang(tangent)+90 if bUseSymbol: positionMarkerSymbolResource() # Check Symbol Resource vs.Symbol(markerSymbol, pt, rotation) # Insert Symbol else: positionMarker(pt, rotation) # Draw non symbol Marker # ----------------------------------------EVENTS------------------------------------------------------------------------ kObjOnInitXProperties = 5 kObjOnWidgetPrep = 41 kParametricRecalculate = 3 kObjOnSpecialEditID = 7 kObjXPropSpecialEdit = 3 kReshapeSpecialEdit = 3 kObjXPropEditGroup = 1 kObjXPropEditGroupPath = 2 def execute(): (theEvent, theButton) = vs.vsoGetEventInfo() if theEvent == kObjOnInitXProperties: vs.SetObjPropVS(kObjXPropSpecialEdit, vs.Chr(kReshapeSpecialEdit)) # Double Click Edit Path vs.SetObjPropCharVS(kObjXPropEditGroup, vs.Chr(kObjXPropEditGroupPath)) # Double Click Edit Path if theEvent == kParametricRecalculate: main() if theEvent == kObjOnSpecialEditID: # Double Click Edit Path vs.EditObjectSpecial(pioHandle, 3) # Double Click Edit Path execute() (This basic script could also be a good starting reference for anybody looking for help creating a simple duplicate along path in the future)
  4. I'm building a simple tool that just does a distribute along path for an object, but it can end up drawing hundreds or thousands of each object along the path depending on the length and at these larger quantities it gets a little slow and cumbersome. This process works better way better just inserting a symbol since all these objects are the same anyway. Rather than having to import this symbol from some external resource file, I've just adapted the original draw script to create a symbol definition resource if its already in the resource library. The problem I'm running into is that if I try to run the create symbol script inside my object the custom object path gets swept up by the script and embedded into the symbol which will then break the rest of the script as the path is no longer part of the PIO. I'm not even sure how this is happening as the vs.BeginSym trigger comes well after the path creation and processing. I've tried moving the symbol creation trigger to a couple different points in the script/event flow and nothing I've attempted prevents this. Does anybody have any recommendations on how to avoid this, or a specific event to handle this creation, or just a better way to avoid creating a symbol?
  5. Anybody know of a way to access the handle of a sheet layer viewport's camera? Coming up dry on this one without manually entering the viewport camera to check its name.
  6. Thanks Pat- that's already the approach I'm using here to build the list. I'm presumably doing this stage correctly as it's getting all the correct data but perhaps this also part of my problem if I'm doing something odd at this stage. Here's a bit more info to clarify: I'm using vs.BuildResourceListN on the Lighting Stands library file and getting all the names added correctly with vs.GetNameFromResourceList and vs.vsoWidgetPopupAdd. In the event script I'm inserting the Widget and this works correctly. if theEvent == kObjOnInitXProperties: #Mostly lifted from _c_'s event example ok = vs.SetObjPropVS(kObjXPropHasUIOverride, True) ok = vs.SetObjPropCharVS(kWidgetGroupMode, vs.Chr(kWidgetGroupAutomatic)) #removed other unrelated inserts to keep this clean and clear ok = vs.vsoInsertWidget(cP___div2 - 1, kWidgetSeparator, cP___div2, O_GetLocParmName(vs.GetName(pioRecordHandle), '__div2'), 0) ok = vs.vsoInsertWidget(symbolContainer-1, kFieldPopUp, symbolContainer, O_GetLocParmName(vs.GetName(pioRecordHandle), '__SymbolList'), 0) Parameters are set in the Plug in Manager. Widgets are linked correctly in the OIP, but the Symbols popup is blank by default. Clicking the popup will show everything that was added to it, but selecting anything from the list will just return the popup to the blank state as seen above.
  7. Struggling with making an OIP Popup object functional- the goal is to just have a text based popup with the a list of symbols from an external resource. I've gotten the popup widget inserted into the OIP, and I've successfully populated it with the names of the symbols from the library file and I have it linked to an existing parameter. However after this I'm not having any luck. The popup is there, defaulting to blank data. If I click on it, it'll pop open and show me the list of symbols but from here clicking on anything doesn't actually set the field and the popup just returns to an empty field. I'm monitoring the events and there doesn't seem to be anything of note happening on selection with kObjOnInitXProperties kParametricRecalculate and kObjOnWidgetPrep cycling as usual after modifying a parameter. What am I missing here?
  8. SetEntityMatrix works like a charm @JBenghiat, even saved me a few lines of code. I'll have to use this one more often. Thanks! @Sam Jones Using SetEntityMatrix on the Lighting Device- the next value sets the X, Y, Z coordinates for the device, and the next three values represent the X, Y, Z rotation values. Example included. HTH # hObj = Handle of Lighting Device (BOOL, pioName, pioHandle, pioRecordHandle, pioWall) = vs.GetCustomObjectInfo() #Gets info from the current PIO zHeight = 48 ptLocation = vs.GetSymLoc(pioHandle) #2D Location of the Custom Plug-in Object xRot = 180 yRot = 0 zRot = 180 vs.SetEntityMatrix(hObj, ptLocation[0], ptLocation[1], zHeight, xRot, yRot, zRot)
  9. Of all the complicated things I spent the morning working through, I can't believe that this is the one that is tripping me up- I'm struggling with properly rotating a lighting device in 3D just to force a fixture into an upright yoked position (180 on y Rotation, or 180x/180z as the OIP will recalculate to). My first attempt at this is using vs.LDevice_SetParamReal however this is doing absolutely nothing and doesn't provide any feedback so it's difficult to understand why. The used values should all be fine based off a previous investigation into this command a few months back. I also tried using the OIP name 'X Rotation' which also does not work (didn't expect it to). I also ran a loop and tried changing the cell and accessory index parameters around just to see if anything work take, but nothing did. vs.LDevice_SetParamReal(hObj, -1, -2, 'xRot', 180) vs.LDevice_GetParamReal(hObj, -1, -2, 'xRot') The Get version of this command works perfectly using the same values and properly retrieves whatever values I manually set the device to. Also, the Get command will retrieve the new values set via the Set command when run after the Set commands in the script, but the end result will still be no change. Running just the get again following this will show to the initial/current values not the values that were supposedly set in the previous script run. I assumed that maybe a reset command must be triggered to update the light but I've thrown LDevice_Reset, LDevice_ResetVisual, vs.ResetObject or the hell of it vs.ResetBBox into the mix but none help this. Eventually I gave up on the LDevice commands and went straight into the record commands which are giving me the exact same issues. I can read it, I can't set it. It shows as changed if I immediately Get following Set but does not actually update the device. vs.SetRField(hObj, 'Lighting Device', 'xRot', 90) x = vs.GetRField(hObj, 'Lighting Device', 'xRot') I went a step lower into vs.Set3DRot and vs.SetRot3D which *KINDA* work. It takes some math to get the points and such all set correctly and I can get the desired rotations but only if I switch views to 3D which gets a little clunky especially when I'm dealing with symbol rotation as well. Without script forcing the views into a 3D view these commands fail in top/plan view since it's a hybrid object. I'm sure I can kludge around this approach a bit more and make this all work, but it really seems like this shouldn't require any sort of work around for something so simple. Is the an approach I'm overlooking, some error in the values or just some bugs here? Anybody have a solution or insight? I feel like I'm missing something obvious here since this process should be a no brainer at this point...
  10. Sorry for the long delay but I haven't been able to dig into this for a while. This is very helpful @MullinRJ, but I'm still struggling with some looping issues. I *think* I've finally narrowed down the problem to the plug in implementation I was using while playing around. I've been playing with as a Point Object Plug In, but with this option I can go through the process of displaying the pop up, selecting from the pulldown and ok'ing the selection and everything works as intended, however it will then retrigger event 12255 and start the process all over again, including when switching over to the modified code that you've provided. If I import the script into a simple menu command script, it all functions perfectly as intended and inserts the selected symbol without issue. So in part, the struggle here is likely my sequence of events if I am to build this as an insert point object... I'll have to dive into that more since this initial pass was really just experimentation to get used to the dialog building rather than creating something specific. Insights on the loop issue would be helpful if anybody has some better understanding of this or can suggest the better approach to using a dialog like this in a point insert object.
  11. I'm working with my first custom dialog display, and all the new stuff is clicking into place just fine, but I'm struggling to figure out the best ways of processing the interaction and not having any luck finding examples or details. Here's the example I've been playing with (might be a few oddities in the code lingering from some of the different approached I've been experimenting with). Right now this is attached to a point insert custom tool, and I'm just experimenting to get an understanding of the flow here- All I'm currently doing is building a simple popup that will show the symbols from another resource file and insert the selected symbol into the custom object. I've got Alerts tied to the dialog handler so I can see all the events that get passed around while I'm figuring this out. Where I'm struggling, is on the symbol insertion step. I'm logging the selection event just fine and getting the resource index from the Thumbnail Popup, and off this event setting a variable to the selected index, under the assumption that then when I click 'OK' it will register the 'OK' press, check that the iSymbol variable has been set and then insert it. However getting this variable passed around is proving problematic. I've tried declaring the variable both inside and outside Dialog_Handler, each have issues and I'm frequently being told iSymbol is getting referenced before assignment. The only way I'm able to make this 'work' is to build the symbol insertion in to the selection in the pulldown but that seems messy and can insert symbols without confirming anything. This also is causing me some looping issues that I'm not clear on the cause. After confirming the symbol, the SetupDialogC event is flagged again. Not sure what that's about... Also, I'm getting an item passed into the data handler as -12613. I dug around and checked the usual places, searches and the MiniCadCallBacks.h file and I can't find anything about what this flag represents. Any ideas? So clearly I'm still not quite getting the full process down, any easy fixes here or examples that can clear up some of the messiness I'm encountering? import vs debugMode = True btnOK = 1 btnCancel = 2 kThumbnailPopup = 101 SetupDialogC = 12255 iSymbol = -1 #bSymbol = False def Dialog_Handler(item, data): #global iSymbol if debugMode: text = 'Running Dialog Handler. Values Returned:\r\ritem: ' + str(item) + ' | data: ' + str(data) vs.AlertCritical('DIALOG HANDLER', text) resourceType = 16 fullPath = "../Libraries/Objects - Building Equip_Appliances/_Office Equipment.vwx" (symList, numItems) = vs.BuildResourceListN(resourceType, fullPath) # (symList, numItems) = vs.BuildResourceList2(resourceType, 0, '', False) if item == SetupDialogC: for i in range(numItems): name = vs.GetNameFromResourceList(symList, i) #if name[:7] == 'zNested': # continue vs.InsertImagePopupResource(dialog, kThumbnailPopup, symList, i) if item == kThumbnailPopup: # Interaction with Pulldown Menu #bSymbol = True iSymbol = data hSymbol = vs.ImportResourceToCurrentFile(symList, iSymbol) vs.Symbol(vs.GetName(hSymbol), (0, 0), 0) if debugMode: vs.AlertCritical('Clicked something in popup, setting iSymbol to: ', str(iSymbol)) #if item == btnOK and bSymbol: # OK Button Pressed and symbol has been selected #hSymbol = vs.ImportResourceToCurrentFile(symList, iSymbol) #vs.Symbol(vs.GetName(hSymbol), (0, 0), 0) #if debugMode: #vs.AlertCritical('OK BUTTON!', 'iSymbol: ' + str(iSymbol)) def CreateSampleDialog(): global dialog iSymbol = None dialog = vs.CreateLayout('Add Choice Sample', 1, 'OK', 'Cancel') vs.CreateThumbnailPopup(dialog, kThumbnailPopup) vs.SetFirstLayoutItem(dialog, kThumbnailPopup) vs.RunLayoutDialog(dialog, Dialog_Handler) vs.SetPref(412, True) CreateSampleDialog()
  12. Still slowly working through things and haven't gotten into the event based stuff yet, but DEFINITELY spending some time playing with this example. Great to see this, I was just thinking about starting to make similar simple example projects to help the community and this is a great reference. Here's a few things I have found so far: -Incorrectly placed control points just seems to be a refresh bug. I've found that creating the control point the in the definition and then later changing it as I'm updating what the defaults should be as my script evolves doesn't take internally. It'll show the new default value but it's still holding the initial default value and sending that into the script. The only way I've been able to deal with this so far is to delete the control point in the definition, exit the plug in manager, (let the script spaz out with errors), and then go back into the plug in manager and create new control points with the corrected values. It's obnoxious but it's simple enough for a couple points since it auto names everything anyway. -Hiding the control points definitely seems to be an event based function because I initially just built the hide portion into and ELSE statement, but when the conditions changed to true it wouldn't come back until I also built the make visible line into the the initial IF portion of the script. Interestingly though, there doesn't seem to be any need to check the Event Based execution in the definition options. Haven't dug into this any further since it's working just fine for my current needs, perhaps there's some distinction here that will become more obvious as I dig into the event based code more.
  13. Excellent, thanks for all the fantastic info @Jesse Cogswell! Lots to dig through here, will take me some time to explore and definitely keep me busy this weekend! The function reference has definitely been my friend lately and has it's own dedicated screen at this point, but knowing what to look for is 90% of the battle- especially when can't just search for a clear term and have to guess on some abbreviations like 'CntrlPt' because searching for 'Control' doesn't help. Also, was not aware of the Script Reference HTML and it looks to be another great resource. I had previously steered clear of the VSO and Event Based stuff as I thought I saw in some post that these were really only available to C++ but looks like I'll need to spend some time reading and exploring this more.
  14. Working on figuring out plug-in tools via Python scripting and have a few questions: -How can I add a separator line to the OIP? Also a slider? Interesting how these are present in Marionette but no direct easy access in the Plug In Manager. -I'm having trouble with the default values on my control points- The defaults are set to values such as (0,30"), however when I insert the object all control points default to (0,0). Nothing in my script is directly updating these values, and they respond to being moved just fine after inserted. -I have a text object that is inserted at a control point, and a Boolean that toggles whether or not the text is displayed- how can I make this also get rid of the control point? -How can I use the Text controls in the menu to adjust the text settings in my object?
  15. Found it while looking at other things: vs.SetSymbolOptionsN A little frustrating that all these options in one spot are adjusted so differently, but at least it's there. Hope this helps somebody else down the line!
  • Create New...