Jump to content

AlHanson

Member
  • Posts

    86
  • Joined

  • Last visited

Posts posted by AlHanson

  1. You basically answered your own question already. 😅 Look at vs.GetZatXY.

     

    It can be a little flakey from my experience though, and works best when you specify the object handle rather than leaving it as None and having it figure things out for you. Even when specifying the object to check against I occasionally still get incorrect results which cause some situational funkiness.

    • Like 1
  2. The PIO is going to function just like a symbol with separate 2D/3D. The stage pieces are being treated as 3d and the dimensions are 2D, hence why you're only seeing the dimensions in 2D. There's a couple different solutions for this depending on your needs:

    1) Assign the dim objects to the ground plane with vs.SetPlanarRefIDToGround() and then they will show in 3D with the rest of it. If everything is 3D it will always draw the same in 2D and 3D. It'll work but it's not always the most optimal approach.

     

    2A) Draw a 2D version of the stage pieces as well as the 3D. Just like a symbol you'll see the simplified 2D version when in 2D only and the full detailed in 3D.

     

    2B) Use vs.Generate2DFrom3DComp() to have Vectorworks figure out the 2D version of your 3D for you. It can get slow depending on your 3D but would likely be just fine for something basic like some rectangular platforms

     

    • Like 2
  3. Kinda? I never had any luck getting this particular approach of inserting a popup into the OIP to work, but eventually found no reason to approach it in this manner. The easier approach I've been using which I've never had any issues with is just creating a popup field parameter via the plug in editor and then just populating it using the vs.vsoWidgetPopupAdd. Unless there's some reason to not approach it that way, that's my recommendation.

  4. Anybody have an approach for getting the options from a pop-up field in a Plug In Object? vs.PopupGetChoices doesn't appear to work with hidden parametric records from everything I've been throwing at it. Tried both field name and localized field names and I always get 0 for the number of values and None for the list returned when used on a PIO Record. Works fine on standard record definitions in the resource browser. This command didn't exist before v2023 so there has to be an alternate approach I'm overlooking... I hope?

  5. Does anybody know a way to modify a texture’s image shader map to flag the image as Inverted? Trying to make this an accessible option on a batch import script and I can’t track down anything that controls this directly, or even indirectly via records or variables for the shader or the  bitmap on the shader. The shader records themselves only contain the basic parameters and nothing specific to the image. The image field of the shader record always seems to just be ‘4’ for every texture and I can’t figure out what that means, as it’s certainly not an image index. Any thoughts?

  6. Digging a bit deeper today... and it doesn't seem like this is possible at the moment?

     

    VS-List_Browsers_part_4

     

    Went back to this very helpful guide and found there are some specific notes about the LB events that call out direct edit not being VS accessible. Older version listed, but from my testing with it today I'm not receiving any of these events in 2023 either when interacting with an editable field in my browser. Guess we're out of luck for the time being?

     

    Quote

    { LB's direct edit, introduced by VW 2020, not accessibile yet (VW 2021) with VS }

    kLBQueryInteractionType = -16;

    kLBQueryItemValue = -17;

    kLBQueryItemListRetrieval = -18;

    kLBItemEditCompletionData = -19;

  7. @Gelde-Aart

    I actually hit a point on the plug in I was intending to use this on that I didn't wind up needing it. I came across the read only commands while looking for some other info,  plugged them in just to see if it would function and it appeared to work initially. I was able to enter the field and type in new data but that's about all I tested at the time. However when I load that script up today the read only control didn't seem to want to enable anymore at first. After a few tries of me throwing in some debug stuff to try to see what was going on it suddenly finally kicked in and gave me the option to edit the fields, but the new values I type in won't actually stick. I was thinking maybe something would have to be scripted to commit the change, but I tried monitoring the events happening via vs.GetLBEventInfo and while kMessageSelectionChangeClick  (-4) gets flagged when entering the field, no events appear to occur when committing or exiting the field after a change.

     

    So there's something more to this I'm missing... I'll have to dig in deeper whenever I can find some time to experiment and see if I can figure this out.

  8. I'm struggling with adding a resource popup widget to my OIP.

     

    I can make a resource popup work with using a kWidgetButtonResourcePopup (105) and then calling vs.vsoButtonGetResource when the widget button is pressed just fine, but it sure isn't as pretty as the actual resource popup. 😁

     

    Whenever I use kWidgetResourcePopup (107) I'm adding the popup to my OIP just fine, however there's no data there and it's just greyed out.

    kWidgetResourcePopup.png.c4f0867c3b4e89ba75c431fca0f8da5c.png

    Clicking on it doesn't cause the resource pop up to display like with the button, nor does it do anything in terms of flagging events like the kWidgetButtonResourcePopup approach.

    I've enabled kObjXPropSupportResourcePopup (53) via vs.SetObjPropVS during kObjOnInitXProperties.

    I've tried using vs.vsoWidgetPopupAdd(N) to feed random data to it which doesn't seem to be the way to go about this.

    Doesn't seem to be a way to link it to a resource list that's been built...?

     

    What am I overlooking here to make this work? 

  9. Is it possible to edit/enter text/dimension fields directly in a List Browser? I don't seem to be finding any function controls for this nor seeing any details in any of the resources I've spent the past hour digging through. Anything I'm overlooking here or is this just not possible at the moment?

  10. Didn't ever see any alerts that there was a response here!

     

    Correct, this is just a bunch of light objects in spotlight mode. The code creates some lists for the general properties for the light and then applies everything using the basic property adjustment commands for the spotlight in a For loop for the list of insert points. I've tried disabling some of the other property setting commands to make sure they aren't having any possible impact and I still get the same results when running. So this is the bare bones of what's going on:

     

    for pt in ptList:	#for each point in the list of insertion points
    	hLight = vs.CreateLight(pt[0], pt[1], pt[2], lightTypeDic[lightType], bLightIsOn, bCastShadows)	#Insert a light
    	vs.SetLightColorRGB(hLight, rgb[0], rgb[1], rgb[2])	#Set the color of the light

     

    Everything is still functioning correctly in the tool. Colors are clearly set correctly on the light objects, they just don't render any output properly in Shaded Render mode, but will render correctly in Final Quality. This screams bug to me based on that fact unless there's something else I'm overlooking.

  11. I have a custom tool to create lighting arrays with color patterns and gradients that I was excited to give a go in 2023 now that it supports more than 8 lights in Shaded Render mode, but straight out of the box my plugin isn't working right.

     

    I started by loading up a test file of a lighting array created in v2022 and all the lights show the correct color at the source, but only project white light in Shaded Mode. Rendering in Final Quality will produce the correct color however. 

    131144649_Screenshot2022-10-22135449.thumb.png.5468b27bb6d20b91c5078ec18bed971b.png1594817361_Screenshot2022-10-22135432.thumb.png.8f57a853a67517fcafb1d83f27f3cee9.png

     

    If I insert a fresh PIO using the tool none of the lights will actually output anything in Shaded Render, but again will render as intended in Final. 

     

    If convert the PIO to a group and have access to the individual light objects, they still do not work until I manually change the color and then they will start rendering correctly in Shaded.

     

    I dug through the VectorScript Function reference and nothing seems to be new or different here in regards to lights that's immediately jumping out at me as something that would impact this in the code. While I'm sure the code I've written is a bit old, janky and in need of some cleanup, the overall function is very basic in terms of Create a Light and Set its values, so nothing here seems like it should be a code problem necessarily.

     

    Anybody else encountering anything like this and have some knowledge on working with lights in the updated rendering mode that might help explain this? 

     

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

  13. 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)

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

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

    333421221_Screenshot2021-04-26103346.thumb.png.fbcc2311d14261454bce98ecbd2b233e.png

     

    Widgets are linked correctly in the OIP, but the Symbols popup is blank by default. 

    1366869878_Screenshot2021-04-26103419.thumb.png.d7f72c35104d16147f51d0c29ac5d0a9.png

     

    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.

    1022610045_Screenshot2021-04-26110139.thumb.png.fda0b1f4d40204426fead21d573063d4.png

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

  17. 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)

     

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

     

×
×
  • Create New...