Jump to content


  • Posts

  • Joined

  • Last visited


384 Spectacular


Personal Information

  • Occupation
    Circuit Board Designer
  • Location
    United States

Recent Profile Visitors

3,895 profile views
  1. 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
  2. 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
  3. 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
  4. I may have, but I’ll have to check when I get home. About 2 hours, I’m guessing. Raymond
  5. I added a VE for this feature. [VE-103866] Add VS command capability to query and set the visibility of all standard VW palettes.
  6. 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
  7. 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. 🙂
  8. @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
  9. @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
  10. @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
  11. 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
  12. 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
  13. 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
  14. 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
  15. @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
  • Create New...