Jump to content

JBenghiat

Member
  • Posts

    2,031
  • Joined

  • Last visited

Everything posted by JBenghiat

  1. In general, the starting path for an include is the file from which it is run. For Plug-Ins, this is the plug-ins folder, and for files, it is the document. Alternatively, you can include full paths-- Macintosh HD:Users:Username:VS Includes:file.px|vss Macintosh HD/Users/Username/VS includes/file.px c:\Users\Username\Documents\VS includes\file.px That allows you to have the include file anywhere, which can be very useful. -Josh
  2. Are you aware of the Vectorscript Language Guide? You can find it at the end of the contents in the help app. There are sections on encryption as well as include files. Efficient encrypting can be confusing, but the VSLG is a good place to start. -Josh
  3. The predefined dialogs are a fixed size, and so only support limited string lengths. If your string is greater than 255 characters (I think alert text may be even smaller), you will have to write a custom dialog. I believe there are some dialog examples on the Vectorworks.net main site under Support>Customization>Vectorscript>Examples. -Josh
  4. You're over-complicating a bit. You're setting b to 0, so b:=b+12 will always be 12. You don't need b -- just use x. Px is the same as GetRField(oh, obname, 'x') (also note the corrected syntax). Just use x:=Px. c, a, b, and d are all unnecessary in your reset code. Think of the case statements this way -- cover up the case statements that aren't executed for each event. The variable values should still produce the desired effects. When you handle a button press, the entire script will run twice, resetting the variables to their defaults, once for the button handler, and once for the reset handler. Here is your code stripped down to the essentials. -Josh PROCEDURE Example3; CONST kObjOnInitXProperties = 5; kResetEventID = 3; kObjXPropHasUIOverride = 8; kWidgetButton = 12; kObjOnObjectUIButtonHit = 35; buttonID_1 = 1234; {user-definable index} VAR theEvent, theButton :LONGINT; result :BOOLEAN; buttonEventID :INTEGER; displayString :STRING; thisDoesNothing :LONGINT; x:REAL; objname :STRING; oh,rh,wh :HANDLE; BEGIN { retrieve custom object information } IF GetCustomObjectInfo(objname,oh,rh,wh) THEN BEGIN { retrieve parameters } x:=Px; vsoGetEventInfo(theEvent, theButton); CASE theEvent OF {User has single-clicked the objects icon.} kObjOnInitXProperties: BEGIN {This tells VW to let the object decide what goes onto the Object Info palette.} result := SetObjPropVS(kObjXPropHasUIOverride, TRUE); {Now we manually add the "normal" parameters...} {One way is to use this single call to add all of the existing parameters.} result := vsoInsertAllParams; {Finally, we add the button.} displayString := 'My Great Button'; result := vsoAppendWidget(kWidgetButton, buttonID_1, displayString, thisDoesNothing); END; {User has clicked a button in the Object Info palette.} kObjOnObjectUIButtonHit: BEGIN CASE theButton OF buttonID_1: BEGIN AlrtDialog('Custom Button Dialog'); x:=x+12; SetRField(oh,objname,'x',Num2StrF(x)); ResetObject(oh); END; END; END; {Object reset has been called.} kResetEventID: BEGIN Rect(0, 0, x, 1); END; END; {event Case} END; { if object information was successfully retrieved } END; Run(Example3);
  5. Each event gets run one at a time. In other words, when a button push event runs, the entire script runs, executing only the button case. When the object regens, only the regen case runs. You need to use the object's parameters to pass variables from one regen to the next. In your example, add a distance parameter, x. Add a GetCustomObjectInfo call to get a handle to the PIO and the name of the record (the same as the name of the PIO). Initialize x with x=Px. Use SetRField to store the x value. The field name would just be "x" not "Px". Because SetRfield accepts strings, use Num2StrF to coerce x into a dimension string. A button push will not automatically regen the object, so add ResetObject to the button event. In reset event code use Px instead of x. (or initialize x as part of the reset event as well) -Josh
  6. Yes this is possible. There are several thing to consider. - This functionality should be created via the PIO, and doesn't need to involve a worksheet. - Do your check when IsNewCustomObject is TRUE. This will only be true when you are manually inserting a PIO for the first time. That will make sure the check doesn't happen on a regular regen and that you will only check and warn one object at a time. - Use Count() to see if any other objects have the name field as the same - Keep paramater and variable values separate. For example, start by setting obName:=PName to set your name variable to the parameter. If you need to change the name parameter, use SetRField(). The parameter won't update until another regen, so make sure to update and refer to obName for the rest of the script. Hopefully, this will give you a start. -Josh
  7. Yes, it's possible but it requires an event enabled PIO and hard-coding the button into the OIP. Perhaps start with this link, and search the forum archived for some of the terms. http://developer.vectorworks.net/index.php?title=VS:vsoAppendWidget If the PIO is for your own use, you can always have a checkbox that un-checks itself when clicked. Not elegant UI, but it will quickly give you the functionality you want. -Josh
  8. I don't see any inherent problems in the code. Check to see that your parameter is called "Height," without any spelling errors. FYI, you can nest procedures, compacting the code to: SetRField(oh,objname,'Width',Num2StrF(w)); The only downside to doing so is debugging can be a bit harder. -Josh
  9. Num2StrF will return a string using the current units setting. -Josh
  10. Create a parameter of type Static Text. Use SetRField to assign a value to the parameter. Use GetCustomObjectInfo to get the handle to the plug-in, and the plug-in name. Pass the plug-in name as the record name. Don't include the "P" in the field name. Use Num2StrF to convert any distances to strings. HTH, Josh
  11. Your custom structure looks something like this: TYPE OBJECTDATA = STRUCTURE han :HANDLE; name :STRING; END; VAR objectList :ARRAY[1..50] OF OBJECTDATA; BEGIN objectList[1].han:= ..... objectList[1].name:= ..... ..... SortArray(objectList, 2); -Josh
  12. Joshua, Assuming your class pop-up is called "ClassAAA," your code is correct. It is possible that you are not correctly getting a handle to the object you want to class. Inserting Message(Handle) and checking for a non-zero result could be a troubleshooting step. Also, try duplicating your plug-in and converting to group. You can then look at each component in Object Info and see what is going on. HTH, Josh
  13. Instead of using a multidimensional array, use an array of custom structures. (See the VS Language Guide if Structures are a new concept). Then you can use SortArray http://developer.vectorworks.net/index.php?title=VS:SortArray, passing the number corresponding to the order that you declared the "name" variable in your custom TYPE definition as the last parameter. -Josh
  14. Forgive me if I'm stating known facts, but make sure to check out the VectorScript Language Guide accessible through the help app. Also, VS is based in PASCAL (note, not Object PASCAL), so finding a simple PASCAL tutorial could be useful. -Josh
  15. Thanks Andy. Assuming all your symbols are Spotlight Lighting Devices, Savvy Symbol Key lets you choose which symbols appear in each key and have multiple keys per document. -Josh
  16. OK, one more method. Split the base curve in half. Draw another vertical at the mid-point (now end points) at half the total height. Loft in bi-rail mode, selecting the mid verticals and either the locus or end verticals as the rails. The bottom curve is the profile. (Let the loft keep curves.) You will have two lofts with much less bow. I imagine that if you split the curve into quarters, it would be even more square. -Josh
  17. Benson, I can confirm what you are seeing, and the larger the scale, the greater the offset. I'm not a NURBS expert (any industrial designers care to weigh in?), but I believe what is happening is that even though the base curve is co-planar, the vertices orient in three dimensions. Imagine taking a piece of flexible wire, drawing a stripe at the top, and bending it into an ellipse. The stripe would bow out at the middle. The more your elliptical segment extends towards its end vertices, the greater the bow. There may be ways to manipulate the rail curve to untwist it, but that is beyond me. I can think of two fairly quick fixes to ensure straight sides: - Use the reshape tool to move the top vertices of the loft into place. If you constrain to y (or x if the shape is vertical), the task is fairly fast. - Use the project tool to project the top curve onto an extrude. -Josh
  18. If you're really just using multiple instances of a worksheet, you might not need a script. You can place a worksheet multiple times in a drawing, or you can put a worksheet into a symbol. If you need to enter unique data in each copy, you can copy a resource with CreateDuplicateObject: PROCEDURE MyScript; CONST kWorksheetName = 'My Worksheet'; VAR modelH, newH :HANDLE; BEGIN modelH:=GetObject(kWorksheetName); newH:=CreateDuplicateObject(modelH, GetParent(modelH)); SetName(newH, 'Copy 2'); END; Run(MyScript); -Josh
  19. If you want the deck of your ramp to be the ellipsoidal shape, this object is fairly simple. Either rotate your extrude or set an angled working plane when you draw your 2D curves. Next use the Split Tool, Reshape Tool, or Subtract solids to get you ramp. If you want your ramp to have the footprint of your shape, then you need to use NURBS curves and the loft tool. Start with your two elliptical segments. Convert each one into a NURBS curve with the Modify>Convert menu commands. If you knew the curve of the ramp instead of the footprint, the loft would be more straight forwards. An Extrude Along Path may also work well. Not knowing the curve, the easiest part of the ramp for VW to calculate is actually a side. (I find that mastering solvable lofts takes some trial and error to really understand what VW can calculate), Start with the end of an elliptical side at the bottom, and place a 3D locus. Next go to the top and draw a vertical NURBS segment the height of the ramp. This may be easier if you first convert the line representing the top of the ramp to a NURBS curve, then elevating to height. With the Loft tool, select the single rail mode. Choose the curve as the rail, then the locus and vertical line as profile curves. Click the green check in the mode bar. Preview your curve. The part of the curve you click determines its direction for the loft. If you connect opposite ends of the curve, the preview will appear all twisted. You can correct this in the dialog. You should now have one side of the ramp. Repeat for the other side. You can now use the extract tool to get the top curves, one curve at a time. There are now a few ways to get the top surface of the ramp. I think the easiest is to select the two side curves and the beginning and end edges and selecting 3D Power Pack>Create surface from curves. You now have a group of curves representing the top of the ramp. If you need the whole ramp to be solid, you should be able to fairly easily create the end and bottom, then stitch and trim the whole thing together. -Josh
  20. Just to reinforce Michael's comments, I find that my usual settings for classes are to show/snap/modify and my usual layer settings are anything but /modify. Other settings for classes or the /modify others setting for layers are the exceptions to the rule for a specific task. Keeping those settings in mind may help guide you as to when to make something a layer and when a class. HTH, Josh
  21. In terms of background, I'm not sure what you mean. Are you looking at the fixture in context, or alone in a perspective view? Do you want to see its light hitting something? As for making it light up, look at the symbols in Libraries\Objects-Building Services\Electrical-Accurate Lamps (there are imperial and metric versions). They respond best to Renderworks rendering modes. -Josh
  22. I think there is a line between modeling simulation. VW is an excellent modeler, but it isn't really meant to be a simulator. One question is: what is the purpose for your renders? If you are testing design ideas and sharing them with your clients/collaborators, your best option may be applying the billboards to your walls as decals. If you are just trying to see if the DL3's will work where you have them hung, then have a video screen with a projector coincident to the area of the wall where you want to project. If you really need to see how the DL3 will interact with the scenery, see the beam of light in the air, etc, you may need to turn to more of a simulator -- ESP Vision, WYSIWYG, Capture Polar, Light Converse, etc. My $0.02 -Josh
  23. A few things. If you have a rectangular PIO, there is a clear origin, but identifying the insertion point is less straightforwards, at least to the user. If you do offset the object from its origin, you lose the ability to resize the object via its corners and edges in a logical way. If you have a point PIO, then the insertion origin is more clear. The cleanest way to code this is to define an offsetX and offsetY variable, and add them to every coordinate that you use to draw. Eg. offsetY could be -height/2, 0, or height/2 depending on a top, center, or bottom alignment setting. You should have your script commands work with handles rather than on selected objects. Move() will move selected objects. HMove() will move objects with the specified handle. As PIO code functions on objects within a container, you should use the handle versions of any commands. HTH, Josh
  24. I imagine the issue you are having is that each name must be unique or that setname worked, but you can't see that it did. PIO regen code can run a few times during insertion, so the only way to guarantee a unique name is for the code to check for one. That said, there may be a more elegant solution than using Location and criteria. Have you looked at http://developer.vectorworks.net/index.php?title=VS:PtInPoly and http://developer.vectorworks.net/index.php?title=VS:PtInRect? -Josh
  25. As a rule, I try to add anything that goes on the plot via VW, and that includes practicals. The only time I use LW to add anything that does on the drawing is when the electrician has been maintaing the LW file and I'm getting the two in sync. -Josh
×
×
  • Create New...