Jump to content

Miguel Barrera

Member
  • Posts

    663
  • Joined

  • Last visited

Posts posted by Miguel Barrera

  1. You can link an excel file to vectorworks with ODBC. I use the connection to fill-in fields with vectorscript in a form based on a user selection. However, the primary function of the ODBC connection is to link the database (excel file in this case) to Vectorwork objects with a common key field and it seems that is exactly what you are trying to do.

  2. The problem with resetting the plugin is that the code has to complete before it actually gets reset. It does not happen immediately when it is called. What I do is set a hidden Boolean parameter to true on the first reset event. When the pio goes through the second reset event, it will encountered the true value and execute the code in question and then I will set the parameter back to false.

    • Like 1
  3. My own experience is to change values in the reset event. the typical work flow  is :

     

    1. assign parameter values (either default or user entered) to variables with the P value or GetRField.
    2. find which parameter has changed and update any other variables as needed.
    3. redraw the plugin with the new values.
    4. assign the variables to the corresponding parameters at the end of the reset procedure with SeRField.

    If I see that some value is not changing when it is supposed to I will turn on the debugger and trace the value in question to find out why it is not changing. I work exclusively in vscript because the debugger is readily available. I have tried to setup the debugger in python but with no success and is the main reason I have not jumped into python. If you can get the debugger to work for you, it will help you a lot in finding any bugs in your code. 

  4. Sorry, I got this confused with added buttons where you do assign your own ids. But knowing that parameter ids start at 1 and are added sequentially you can still loop these values. For the second grouping, you could add 100 or any other number to the parameter ids.

  5. it should actually be SetFillBack(h,0,0,0) for black color.

     

    You also need to be careful with the scope of the IF statement. The IF statement should be formatted as:

     

            IF (oldLW = 2) OR (oldLW = 5) OR (oldLW = 7) OR (oldLW = 10) OR (oldLW = 14) OR (oldLW = 20) THEN

                BEGIN
                SetFPat(h,1);
                SetFillBack(h,0,0,0);

                SetOpacity(h,50);

                END;

     

    The BEGIN and END calls are required to mark the start and end of the IF statement. Otherwise if you omit it as shown in your previous script:

            IF (oldLW = 2) OR (oldLW = 5) OR (oldLW = 7) OR (oldLW = 10) OR (oldLW = 14) OR (oldLW = 20) THEN
                SetLW(h, newWeight);
                SetPenFore(h, 0,0,0);  
                SetFPat(H1,0) [zero];
                SetFillBack(h,0,0,0);

     

    Only the SetLW procedure will be executed under the IF statement. All the other procedures following will be executed for all objects.

  6. You will need to add the following 2 procedures after SetPenFore(h, 65535,0,0):

     

    SetFPat(h,1);

    SetFillBack(h, 65535, 0, 0);  {Red fill color}

     

    If you need to find the RGB color value other than red, create a rectangle with the attributes that you want in a blank document. Export the file to Vectorscript and you will find in this text file that the attributes are listed prior to the creation of the rectangle.

  7. In order to parse the events, you will need to call

     vsoGetEventInfo(
                   outObjEvent    :;
                   outEventData   :);

    the first variable is the event number, and the second is additional info on the event. In the case of a button hit, the second variable will be the button id that you assigned when the button was created so there is no error generated if the button has the same id as an event. As a practice however, I do start buttons in the 1001 range to avoid any conflict with buttons defined in vectorworks.

     

  8. Sorry I cannot help you with your Mac. The last time  I owned a Mac was in the early 2000's. I have developed a VS plugin that searches for information contained in an excel file through a Windows ODBC driver and manager app, which are included in the Windows OS.

     

    For the Mac, if there is no ODBC manager included in the OS, you can get one from http://www.odbcmanager.net/ 

    There is also a guide to install and configure a filemaker ODBC connection here (Chapters 3 & 4):  https://fmhelp.filemaker.com/docs/16/en/fm16_odbc_jdbc_guide.pdf

  9.  

    8 hours ago, Don Seidel said:

    Vectorscript? Why? It's (year) 2017...VW is supposed to "connect" to an external DB without fuss. Particularly on the Mac OS and particularly with FM Pro, it should be a snap. One should NOT have to be a VS or DB Geek to set it up and make it work, and yet the instructions are not clear & simple. I've looked but never seen a simple VW file example w/ associated DB. 

     

    Don, you can do a lot more with the database through programming than just a simple one to one relationship as it is in the VW interface (link a row to an object with a common key field). You could for example, import a database or spreadsheet into a VW worksheet by choosing the file from a folder dialog or do searches to get a particular data, etc.

     

    I think that those that have not worked with ODBC, do not know that the first step is to connect the database to the ODBC driver, which translates the original format to a SQL database. This is done in the OS and not in VW. In windows you use the ODBC Data Source Administrator (odbcad32.exe) to make an ODBC alias. The alias then can be connected to VW through the "Manage Databases..." menu command. You can't make it simpler than that due to all the different databases around.

     

    I have done some research and found that the first step can be done in python with the following code:

    import pyodbc
    
    # Specifying the ODBC driver, server name, database, etc. directly
    cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=localhost;DATABASE=testdb;UID=me;PWD=pass')
    
    # Using a DSN, but providing a password as well
    cnxn = pyodbc.connect('DSN=test;PWD=password')
    
    # Create a cursor from the connection
    cursor = cnxn.cursor()

    so it is feasible to do all the connections within Vectorworks to access the data.

  10. Adding 3D polygons between co-linear 3D points should fix the problem. As illustrated in your images, there are some points that cross the co-linearity of the the 3D points but if you add a 3D polygon or line, the DTM triangulation algorithm will not cross the line. 

     

     

    screenshot_16.jpg.20c6a6041210c16715b2b736fec2eac2.jpg 

×
×
  • Create New...