Jump to content

Rick Francken

Member
  • Posts

    68
  • Joined

  • Last visited

Posts posted by Rick Francken

  1. Rats! I was hoping there was. Well thank you anyway, Katie. I won't have to pull my hair out now...<g>

    I am glad to see it is on the Wish List. If that functionality were implemented and then exposed in Vectorscript, I can think of some useful applications for it.

  2. ...Is it possible to automate the creation of textures with VS?

    If I have a bunch (like 3000) colour samples as JPG-files, can they be converted to textures? I could have a text file of the names I want to process.

    The texture type would be "Image Color".

    Petri,

    It is possible, but...there are some things I haven't figured out yet. The main one is how to do it silently, ie., without dialogs showing for each image.

    Here's what works so far. First create the Texture. Then use the texture handle to create the shader record. Then use the Shader Record handle to create the Texture Bitmap.

    var

    hTexture, hShader, hBitmap: handle;

    begin

    hTexture:= CreateTexture;

    {if the texture handle is not nil create the shader record }

    if hTexture<>nil then

    hShader:= CreateShaderRecord(hTexture, 1, 15);

    {NOTE: 1 in this case means Color shader record family, 15 means Wrapped Color Image prototype, as defined in the Vectorscript Function Reference.}

    if hShader<>nil then

    hBitmap:= CreateTextureBitmapN(hShader);

    {NOTE: From what I have found so far, the "CreateTextureBitmapN" function and the "CreateTextureBitmap" function are the only ones that give a valid texture bitmap, and I was hesitant to use CreateTextureBitmap because it is marked as obsolete.}

    end;

    If you have references to the texture and shader record and texture bitmap, you can set the properties using the other Texture functions.

    Cheers,

  3. Hi Petri,

    I haven't tried this, but...

    Assuming "hObject" is the handle to your object that has gradient fill

    var

    GradientIndex: longint;

    GradientName: string;

    begin

    {try this first}

    GradientIndex:= GetFPat(hObject);

    {if that doesn't work, try this instead}

    GradientIndex:= GetObjectVariableLongint(hObject, 695);

    {now that you have the index of the gradient, you can get its name}

    GradientName:= Index2Name(GradientIndex);

    end;

    Try creating a simple rectangle with a gradient fill, and then export a file as Vectorscript. Then you can see what VS functions are used to define the gradient, as well as what functions are used to set the gradient as a fill for a particular object. In this case I noticed a line that looked like this:

    SetObjectVariableLongInt (objectHandle,695,result * -1);

    According to the VS Function Reference for the GetFPat function, "A negative value corresponds to internal index of a vector fill pattern applied to the object". Also, the 695 Object Selector is Object Fill Style. Since we want to find the value, use the "Get??" function instead of the "Set??" function.

    Good luck,

  4. Islandmon,

    Thanks. I use a variation of that to place other custom objects along a path polyline, where the objects have to be aligned with the curve of the path. It's a very useful way to place repeating elements.

    I did observe the same behavior you are seeing, and it happens whether the polyline is closed or open. Still trying to figure out a fix for it...not much documentation available.

  5. Hi Luca,

    You can use the "PointAlongPoly" from the VWPluginLibraryRoutines.p file.

    The function is declared like this because the mechanism that generated the file can't handle Vector types:

    PointAlongPoly(h: HANDLE; dist: REAL; VAR ptX, ptY, ptZ: REAL; VAR tangentX, tangentY, tangentZ: REAL) : BOOLEAN;

    So you need to use the function as though it was declared like this:

    PointAlongPoly(h: HANDLE; dist: REAL; VAR pt: vector; VAR tangent: vector): BOOLEAN;

    Here is a simple script that shows how you would use this function.

    procedure MyPoly;

    const

    PointSpacing = 5cm;

    var

    PolyHand: handle;

    pt: vector;

    tangent: vector;

    pointDist, PerimeterLength: real;

    ptresult: boolean;

    begin

    {create a polyline and get its handle}

    CallTool(-204);

    PolyHand:= LSActLayer;

    { get the perimeter length of the polyline }

    PerimeterLength:= HPerim(PolyHand);

    pointDist:= 0.0;

    {draw points 5cm apart }

    while pointDist<PerimeterLength do

    begin

    ptresult:= PointAlongPoly(PolyHand, pointDist, pt, tangent);

    Locus(pt.X, pt.Y);

    pointDist:= pointDist + PointSpacing;

    end;

    end;

    run(MyPoly);

    Good luck,

  6. Hi Tom,

    I use SetRField to update Parameters within the custom object, and the Plugin Object seems to update correctly. However, it's the last step I do in the code after all the drawing has been done.

    Here's what typically might happen..

    -Assign the parameter value to a variable using the "variable:= PParameter" form.

    -Constrain the variable to a min/max range

    -Apply other calculation rules to the variable value

    -Draw the object using the value of variable, not PParameter

    -Update the Parameter value using "SetRField(objectHandle,objectName,ParameterName,Num2StrF(variable))"

    -Call ResetObject

    With that sequence you really don't need to work with events.

    Not much vectorscript documentation is available on events. Most of the information I have found is from crawling through the SDK header files, and reading the Vectorscript Discussion List. I have worked with event enabled objects, and use the "vsoGetEventInfo" function instead of the "GetEvent" function.

    If you have subscribed to the Vectorscript Discussion list, you can search the archives for "event" and Charles Chandler to find more info on event-enabled objects.

  7. You can lock the angle by:

    "Set Grid" to the angle that you want and then use the "constrained" dimension tool. Even after the grid is rotated to normal, the dimension will remain locked to the original angle.

    It's a bit cumbersome, but I've found that the "set grid" command is so often used for a variety of tasks that I've added it to my pet palette.

    Matthew,

    That does the trick. In my case, I set the grid angle by using the "Next Mouse Drag" option, and I'm off to the races. That one is worth putting in my toolbox. Thanks!

  8. I must be overlooking something basic here...

    Is there a way to create a rotated dimension in Vectorworks?

    In Autocad, you specify the rotation angle after you have picked the start point and end point of the dimension. Autocad creates a constrained dimension at the angle that was input.

    It seems like Vectorworks only allows the constrained dimension to be horizontal or vertical. If you rotate the dimension, it appears to become unconstrained.

    Is there some setting or preference that I need to change?

  9. Hi Suds,

    If you paste directly into Vectorworks, it comes in as a bitmap, as you observed. But if you create or open a worksheet from your Resource Browser, you should have no trouble pasting the data that you copied from Excel directly into the worksheet.

    The key is, remember that there is a "worksheet" resource, and there is a "worksheet data" object to represent the worksheet graphically. Not unlike a symbol and an instance of a symbol.

    So the steps I took to copy and paste were as follows:

    1). In Excel, select the range of cells you want to copy.

    2). [CTRL] + C, or the Copy command in the menu.

    3). In VectorWorks, bring up the Resource Browser.

    4). In the Resources Pane, right-click, and select the menu item "New Resource in <file name>...>", and choose "Worksheet..."

    5). When the "Create Worksheet" dialog shows, name it the way you want, and make sure that you have at least the same number of rows and columns as the selection you did in Excel.

    6). Make sure you click in the open Worksheet editor to set focus to it.

    7). [CTRL] + V should paste the Excel data right into the worksheet.

    Now you edit and format the data with all the Vectorworks worksheet functions, and then drag and drop from the Resource Browser onto the drawing screen to create the worksheet data object.

    Good luck, and let us know how this works out for you.

    Regards,

  10. Hi someonenamedlink,

    One possible problem may be with the use of "Str2Num" function to convert the parameter value form string to floating point number. I had trouble with this one working on certain number formats, so I use "ValidNumStr" and "ValidAngStr" instead.

    Try breaking your call down to several lines of code so that you can inspect the variable values more easily in the debugger. Maybe something like this:

    procedure CalculateTotalMeters;

    var

    TotalLength: real;

    BreedteStr: string;

    BreedteVal: real;

    {procedure used by "ForEachObject" call}

    procedure AddLength(hGevel: handle);

    begin

    {get the Parameter's contents in string form}

    BreedteStr:= GetRField(hGevel,'D - Gevelopening','Breedte');

    {try to convert string contents to real, and provide a default value if "ValidNumStr"} fails}

    {NOTE: be sure to inspect the values of BreedteStr and BreedteVal, and whether ValidNumStr is failing.}

    if not ValidNumStr(BreedteStr, BreedteVal) then

    BreedteVal:= 0;

    {add the floating point value to the Total length}

    TotalLength:= TotalLength + BreedteVal;

    end;

    {main code block}

    begin

    {StartWith a total length of 0.0}

    TotalLength:= 0.0;

    {iterate through all the PIOs with ForEachObject;}

    ForEachObject(AddLength, (R IN ['D - Gevelopening']);

    {Now do something with TotalLength}

    Message(TotalLength);

    end;

    Good luck,

  11. quote:

    Originally posted by Lyndsey Darryl Ferguson:

    Did you create a 22x22 PNG image file?

    Lyndsey,

    Are you saying that the image has to be 22 x 22?

    Here I'd been trying to work with a 24 x 24 bitmap, and having all kinds of trouble getting it to display properly.

  12. Hello Nicholas,

    "504Mb RAM, 756Mb Virtual memory"

    This line caught my eye. Not the Virtual memory setting, but the RAM. If it's showing 504, then that means that 8MB is allocated to the onboard graphics adaptor. Try bumping it to 32MB for starters.

    This setting usually can be changed in the BIOS setup (don't know if Dell provides an interface in Windows to change it).

    Regards,

    -Rick Francken

  13. Is there a Vectorscript function for the "Section Solids..." menu command?

    I have found the corresponding Vectorscript functions for "Add Solids", "Subtract Solids", and "Intersect Solids", but have not found one for "Section Solids". Does it exist?

    I observed that when you Export Vectorscript, if there is a solid section object in the document, the Vectorscript file is corrupted and cannot be re-imported.

    The pattern appears to go like this:

    for an Added Solid, Intersected Solid, or Subtracted Solid...

    var

    tempHandle, tempHandle1, tempHandle2: handle;

    result: integer;

    result:= AddSolid(tempHandle, tempHandle1, tempHandle2);

    result:= SubtractSolid(tempHandle, tempHandle1, tempHandle2);

    result:= IntersectSolid(tempHandle, tempHandle1, tempHandle2);

    For Section Solid I would expect the same thing...

    result:= SectionSolid(tempHandle, tempHandle1, tempHandle2);

    Instead the line is written like this:

    tempHandle, tempHandle1, tempHandle2);

    Is there a way around this issue using Vectorscript?

    -Rick Francken

  14. mattb,

    just a guess...in your loop you are creating a new object each time with the "Symbol(sym,x,y)" call, meaning that you just added another object to the list. So your code will continue to find a NextObj. If you are only iterating over selected objects, deselect the newly created symbol reference, I think it's

    "SetDSelect(LNewObj)"

    or something like that.

    If that doesn't fix the problem, you may have to structure the loop differently, maybe start with the last object and work backward with "PrevObj", or use a "For i:= 1 to ObjectCount do"

    Hope this steers you in the right direction.

    -Rick Francken

  15. Hi Tom,

    Go into the Vectorscript plugin editor.

    Select the command plugin you want to encrypt.

    Click "Duplicate" to make a backup of your VSM.

    In Windows, hold down SHIFT+CTRL+ALT when you click on the "script..." button

    In Macintosh, hold down CAPS LOCK+SHIFT+OPTION+COMMAND when you click on the "script..." button.

    For more info, look in the VW Help under "Vectorscript Guide"..."Script Encryption"..."Encrypting Scripts"..."Plug-ins"

    Good luck,

    -Rick Francken

  16. Martin,

    I'm sorry. That first test ran no problem in VW 11.0.1; when I tried it in VW 11.5.1 I got the same behavior you described.

    When I ran through with the debugger in 11.5.1, I observed that the Handles stayed nil after the Arc calls. Even stranger, occasionally the variable window was completely blank. Not sure what is causing that except maybe the Editor plug-in got corrupted and is trying to access the wrong thread.

×
×
  • Create New...