Jump to content

MullinRJ

Member
  • Posts

    1,994
  • Joined

  • Last visited

Everything posted by MullinRJ

  1. You’re welcome. But I think my day ran a few hours later. I’m just now getting up. 😫 😶 ☀️
  2. I figured it out. When I tried to manually select a window and then the wall, VW popped a message at the bottom of the drawing window saying: the wall object could not be selected if an in-wall object is selected. So, selecting the wall AND the inserted PIO with a script results in ONLY the PIO being selected. The order of selection is not important. I learn something new every day, even when I don't want to. Raymond
  3. @Pat Stanford, Try this. It works, but I don't know why. This is using your variable names. SetSelect(H1); { Wall handle } SetSelect(H2); { handle to sub_object in Wall } And so does this: SetSelect(H2); { handle to sub_object in Wall } SetSelect(H1); { Wall handle } Go figure!?! Raymond
  4. Hello, David. HINT: Pat's second suggestion is what you need. Try this code snippet. No error checking is done, so you'll have to add your own. PROCEDURE xxx; { Report the type and the PIO Name of a selected wall item. } VAR H, subH :Handle; B :Boolean; I :Integer; P :Vector; BEGIN GetPt(P.x, P.y); B := GetPickObjectInfo(P.x, P.y, H, subH, I); message(GetTypeN(subH), ' ', GetName(GetParametricRecord(SubH))); SysBeep; END; Run(xxx); HTH, Raymond
  5. What @Pat Stanford said, and... You can use NewField() to update the default value of an existing field in a record format after it exists. This only affects the field value stored in the record format but not any field values in existing records already attached to objects. It will affect new records when they are attached to objects. HTH, Raymond
  6. @stevenmorgan94, First off, what error are you getting? I assume you are getting syntax errors because vsoWidgetPopupClear(), and vsoWidgetPopupAdd() are not functions. They don't return values. If you're getting other errors, it might help to know what they are. Secondly, build your OIP with an empty popup widget to make sure you have all your widgets in place – sans errors. Then, you can add the symbol names to the popup in a loop. Something like this: vsoWidgetPopupClear(2); I := 1; SymNam := GetSymNameWithRec(I); { user defined function } while (SymNam <> '') do begin vsoWidgetPopupAdd(2, SymNam, SymNam); I := I + 1; SymNam := GetSymNameWithRec(I); end; { for } Raymond
  7. Hi @fuberator, There are several documents you need to script effectively. 1) The VW Script Function Reference. There is an HTML version in the VW Application folder, here: /VWHelp/Script Reference/ScriptFunctionReference.html. 2) There is also an online version of the same document, and a whole lot more at: https://developer.vectorworks.net/index.php/Main_Page 3) There are files in the SDK containing lists of the constants used in the program. You can download the SDK here: https://www.vectorworks.net/support/custom/sdk/sdk_license The files you need most are : ProgramVariables.h and ObjectVariables.h, located in the SDKLib/Include/Kernel/API/ directory. If you get this far you're probably numb from the neck up. Sadly, there is not an official Starting Place. We all recommend jumping in then requesting a life preserver. Luckily, there are many people standing around who will gladly throw you a floating device. But, to give you a nudge in the right direction, look in the VW Script Function Reference for the commands that @Pat Stanford mentioned above. You'll have lots of questions, and we'll have lots of answers. Good luck and welcome to the Deep End of the Pool, Raymond
  8. To the best of my knowledge, you cannot create a persistent floating palette as you pictured above. You can create a dialog with those options, but it needs to open and close so you can continue editing your file. I believe what @Pat Stanford is suggesting is creating a Script Palette that contains Pascal or Python commands to achieve the various drawing states you desire. You can also turn these script commands into Menu Commands, which can be loaded into your workspace and assigned hotkeys. These would be available in every open file (new or old), as opposed to a Script Palette which would have to exist in each file, either by copying it in, or adding it to your Template Files. Menu commands can perform simple or complex functions, and if you need to provide user input, they can open dialogs like the one you designed above. If you need help going down one of these paths, please write back. Raymond
  9. Hi @Pat Stanford, No, I have not used ImportResToCurrentFileN(). I have used the older call ImportResourceToCurrentFile() without the callback procedure/function, and it worked perfectly. Raymond
  10. I may have, but I’ll have to check when I get home. About 2 hours, I’m guessing. Raymond
  11. I added a VE for this feature. [VE-103866] Add VS command capability to query and set the visibility of all standard VW palettes.
  12. Hi @Nik, Good question. Complicated answer. As @Pat Stanford implies, there is no elegant solution. However, the ForEachObjectInLayer() function (FEOIL) can get you there, but it's still not an elegant solution. I am posting a VS code snippet and I'll leave Pythonizing it to you. The FEOIL call does all of the work on its first iteration, but it is geared to iterate over all of the objects in the drawing, only being constrained by its search arguments (3, 0, 2 in this case). The trick to get it to stop on the FIRST selected object is to have its "actionFunction" return TRUE immediately, which causes it to STOP iterating. Usually, no boolean value is returned in an actionFunction, which is equivalent to returning FALSE each time, and FEOIL will iterate through the whole document. Function FSObj :Handle; { Return a handle to the first visible/selected object on the Active Layer, or } { the on first Visible Layer if the Show/Snap/Modify LayerOption is enabled. } { If nothing is selected, return NIL. } Var ObjHnd :Handle; Function FSEL(H :Handle) :Boolean; Begin ObjHnd := H; FSEL := True; { return after first object } End; { FSEL } Begin { FSObj } ForEachObjectInLayer(FSEL, 3, 0, 2); { Visible/Selected objects, Shallow, Visible Layers } FSObj := ObjHnd; End; { FSObj } If you want to limit the FEOIL function to only process Editable Layers use: ForEachObjectInLayer(FSEL, 3, 0, 4); { Visible/Selected objects, Shallow, Editable Layers } Happy New Year, Raymond
  13. Hey @Sam Jones, What @Pat Stanford said, AND, is your User Origin Shifted? If it is, you also have to remove that distance from the equation. From your comment, "SetParent() seems to be the problem.", have you verified that you have a handle to the two objects in question? I have never had a problem with SetParent() if the handles are valid and of the correct type. Also, be careful mixing objects of different types – Screen Plan, Layer Plane, and 3D objects. Mixing them will affect their visibility in different views. You know, you could make this a whole lot easier if you'd post a file with your symbol in it. There's a lot of guessing going on here. I hope you're grading us on a curve. Merry Christmas to All, and to All a good night. 🙂
  14. @Sam Jones, Hope you're having a relaxing day, VS problems aside. Your code (and my code) works on my system. Are you using 2D or 3D Symbols? There is a difference. Raymond
  15. @Sam Jones, Just remember that the (0,0) point inside a symbol definition is the Symbol's Insertion Point. In Pat's example, and you place the Locus outside the Symbol and want it in the same relative position inside the symbol, move the Locus by MINUS the symbol's insertion point. Try this. PROCEDURE xxx; { Move Locus into a Symbol at the same position as it was outside the symbol. } { Place a symbol, place a locus, select both, run script. } VAR Hsym, Hsdef, Hloc :Handle; Psym :Point; BEGIN Hsym := FSActLayer; Hsdef := GetObject(GetSymName(Hsym)); Hloc := LSActLayer; GetSymLoc(Hsym, Psym.x, Psym.y); if SetParent(Hloc, Hsdef) then begin HMove(Hloc, -Psym.x, -Psym.y); ResetBBox(Hsdef); SysBeep; { make noise when done } end; { if } END; Run(xxx); Are you writing code that needs to work if the User Origin is shifted? If so, I could write a lot more on how to manage coordinates between Drawing Layers and Symbol Definition spaces. If you also want your code to work in Rotated Plan View (ugh), I can help you there, too, but you'll need a good night's sleep and a large bottle of Aspirin. Merry Festivus 😉 Raymond
  16. @Jesse Cogswell, Wow, you posted THE question I had yesterday, before it left my head! SPOOKY!!! I tried everything you mentioned above with the same result – ¡NADA! If the standard palette names do exist somewhere I have not found them. This seems like a necessary function set to have. If you post a VE, I'll definitely upvote it. I'd really like Get/SetPaletteVisibility() to work on all of the standard palette names. I could have used it as soon as yesterday. Thanks, Raymond
  17. Hi @Pat Stanford, Thank you for the quick answer. It seems all the the *WSSubRow* VS commands are Read Only. Sad – another group of GET commands without the corollary SET commands. I understand *WSSubRow* value commands being Read Only, but *WSSubRow* attribute commands should be Read/Write. I'll file a VE in the morning. Thanks once again, Raymond
  18. Is there a way to set the height of a single database row via Vectorscript? SetWSRowHeight() only takes integer values for Rows. As an example, I want to set database row 5.1 to a height of 0 and leave all the other 5.x database rows alone. I can do it manually, but I want to do it in a script. I assume this is not possible but I hope I am wrong. TIA, Raymond
  19. Hello @stayathomedad, One command you might want to use in your script is: GetObjectVariableInt(LyrHnd, 154)); { return the layer type of the layer referenced by LyrHnd } where LyrHnd is a handle to a layer. This function will return a value of 1 for Design Layers, or 2 for Sheet Layers. Use this to test the layer handle before you delete it. For example: Message(GetObjectVariableInt(FLayer, 154)); { return the layer type of the First Layer in the drawing } will always return 1, because there is always a design layer in a file and design layers are always stored below sheet layers. Conversely: eg. - Message(GetObjectVariableInt(LLayer, 154)); { return the layer type of the Last Layer in the drawing } can return 1 or 2. If there are any sheet layers in a drawing, the Last Layer will always be a sheet layer and the function will return 2. If there are no sheet layers in a drawing, then the Last Layer will be a design layer and the function will return 1. HTH, Raymond
  20. You were very close. The only thing missing is the last line. You need to tell the function to return its answer with: GetTextBlock := ht; I assume ht is a global variable? For transportability, you should make ht a local variable like this: FUNCTION GetTextBlock(h:HANDLE):HANDLE; VAR ht :Handle; BEGIN Locus(0,0); h:=LNewObj; ht:=PrevObj(h); SelectObj(ht); DelObject(h); GetTextBlock := ht; END; {gettextblock} As you've written your code, do not delete ht from your global variables. ht can be both a local and global variable, as long as it doesn't confuse you. So with the above modified function, you will still write: ht:=GetTextBlock(h); in your main code. Raymond
  21. @SamIWas, This first code snippet is an annotated, verbose version of Waldo, as a function. It returns a handle to the FIRST SELECTED OBJECT in your current editing window so that your scripts will work even when you are not editing on a Design Layer. To use, place a copy of the Waldo function at the top of your code and replace H := FSActLayer; with H := FSWaldo; in your code. Modify this function as needed to achieve your desired functionality. Function FSWaldo :Handle; { Return a handle to the first selected object in the present context of the drawing window. } Var H, H1 :Handle; Begin Locus(0, 0); { drop a breadcrumb, a Locus } H := LNewObj; { H now contains a handle to the Locus } hMoveBackward(H, True); { move it to the bottom of the stacking order, but stay within the current container } H1 := NextSObj(H); { get the handle to the next selected object above your locus, or NIL if there are none } DelObject(H); { discard the locus } FSWaldo := H1; { return the handle in H1 } End; { FSWaldo } Here are two streamlined versions of Waldo to replace the FSActLayer and LSActLayer functions. These WALDOs will enable your scripts to work in any window you can open in Vectorworks. Function FSWaldo :Handle; Begin Locus(0, 0); hMoveBackward(LNewObj, True); FSWaldo := NextSObj(LNewObj); DelObject(LNewObj); End; { FSWaldo } Function LSWaldo :Handle; Begin Locus(0, 0); LSWaldo := PrevSObj(LNewObj); DelObject(LNewObj); End; { LSWaldo } @SamIWas, if you would, please describe where you got confused in your previous implementation. It may help me describe this more clearly in the future. HTH, Raymond
  22. Hi @klinzey, Last week I tested how the order of objects are returned by ForEachObject() to clarify how it responds in Single-Layer vs. Multi-Layer modes. I found in Single-Layer mode it returns objects in Stacking Order, bottom of stack first, top of stack last; but in a Multi-Layer mode (Show-Snap-Modify Others) it still searches objects on a layer the same (bottom to top) but it searches the layers top to bottom. This was not obvious or expected, but I'm glad I finally looked. I hope this helps others who are curious about how ForEachObject() works. Raymond
  23. Have you ever heard of WALDO? No, you are not missing anything in the VS API. There is no command to get a handle to any object when you are inside a container object (SymDef, Group, Sweep, etc.) But there is WALDO. He's very useful when you want to run a script and you are editing inside a container object. WALDO works like this: 1) Drop a 2D Locus anywhere – (0,0) is as good a place as any. 2) Get a handle to the Locus with H := LNewObj; 3a) Get a handle to the previous object with H1 := PrevObj(H), or H1 := PrevSObj(H). Now you are at the top of the stacking order. or 3b) Move the Locus all the way to the back and get a handle to the next object with H1 := NextObj(H) or H1 := NextSObj(H). Now you are at the bottom of the stacking order. 4) Delete the Locus with DelObject(H). WALDO (if you make it a function) returns H1. Your scripts can now run INSIDE container objects if you use WALDO instead of FActLayer, or FSActLayer, or LActLayer, or LSActLayer. Waldo works on Design Layers, too, so you don't have to worry about where you are when you run a script. Welcome to Waldo World, Raymond
  24. Hey, Pat. Pity, there are too may ways to recalculate a WS. You are right, it doesn't work if a WS isn't open for editing and its image gets recalculated. As someone who doesn't use WSs very much, that is not the way I typically work, but I am in the minority in this regard. If there is a way, I hope you find it. Raymond
  25. Hello, @Thomas K., and @Pat Stanford. Does this work? =RUNSCRIPT('GetWSName') where 'GetWSName' is a one line VS: WSScript_SetResStr(GetName(GetTopVisibleWS)); I hope I understand your question correctly. Pat, if you don't mind me heeding your recent advice, "This is exactly the type of problem that WSScripts were intended to solve." I think you nailed it. Raymond
×
×
  • Create New...