Jump to content

Julian Carr

  • Posts

  • Joined

  • Last visited

Posts posted by Julian Carr

  1. Thanks for the suggestion Josh. Unfortunately it doesn't work as the string remains in scientific notation.


    If you draw a Space object in a file with units set to mm then run this script:


        perimValueStr = vs.GetRField( vs.FSActLayer(), 'Space', 'Perim' )
        crit_ = "('Space', 'Perim' = "+ perimValueStr + ")" 


    you will get this result:


        ('Space', 'Perim' = 6.4e03)


    If the units are changed to Ft & Ins, then it doesn't work at all and produces an error (could not convert string to float) as the notation value is too long.


  2. I totally agree Pat. Even though Pascal is verbose compared to Python and doesn't have the same community support or external libraries, it requires special knowledge to understand the syntax.


    Anyway thanks to you I figured a way to do it, though it only works with files in metric units. If you draw a Space, leave it selected the run this script, you will see the desired criteria string:


    perimValueStr = vs.GetRField( vs.FSActLayer(), 'Space', 'Perim' )
    (Flag, perimValue) = vs.ValidNumStr(perimValueStr) #convert notation string to real number
    perimValueStr = format(perimValue, '.4f') #convert real back to string to 4 decimal places
    crit_ = "('Space', 'Perim' = "+ perimValueStr + ")" 



  3. Well I guess you are correct Pat, and thanks for your reply. It is already a number expressed in scientific notation, but that can't be used in a criteria string. This is the error it gives:


    Error: Unable to parse Search Criteria.

    Database(('Space'.'Perim' = 9e02))


    so I need a way to change this:


    perimValue = 9e02


    to this:


    perimValue = 900


    Any ideas on that one?

  4. Sometimes when you use GetRField() to return a dimension value from a PIO, it returns the value in scientific notation, so a value of 900 (mm) becomes 9e02. You can use Str2Num('9e02') to convert this to a real number, however this does not work in python and produces this error:


    Type Error. Can't convert 'float' object to str implicitly.


    Here is a code snippet:


    perimValue = vs.Str2Num(vs.GetRField( h, 'Space', 'Perim' ))

    crit_ = "('Space'.'Perim' = "+ perimValue + ")"

    vs.ForEachObject(DoIt, crit_)


    The equivalent in Vectorscript works OK.


    Thanks for any ideas.



  5. I think I worked it out but the result is odd. Using GetVectorFill() you can get the name of the fill. Then using GetType(GetObject(FillName)), you get the object type as follows:


    Hatch: 66

    Tile: 108

    Image: 119

    Gradient: 120



    Here is the test code I used, which works on the fill of the selected object:


    Procedure T;
        h : HANDLE;
        s1 : STRING;
        n : LONGINT;
        Flag : BOOLEAN;
        h := FSActLayer;
        n := GetFPat( h );
        s1 := Index2Name(n);
        Flag := GetVectorFill(h, s1);
        message( n , '  ', s1, '  ', GetType(GetObject(s1)));


  6. Anyone know how to get the type of fill (hatch, tile or image) associated with an object? I know that GetFPat() will return a negative number for these fill types and you can get the name of the fill using GetVectorFill(), however this doesn't give you the fill type. There must be a way??





  7. The only way to achieve this would be to move the symbol instance into the profile group of the PIO, then copy the 3D components from that symbol instance into the PIO. You could do this by cycling through all the objects in the symbol, duplicating anything that is 3D (use GetType()), then using SetParent() to move it from there to the PIO. If the symbol contains planar objects, then you will also need to check if 2D objects are planar and if so, duplicate and move them as well.



  8. Thanks for your reply. To elaborate, I have an event enabled object on a layer (sheet or design). The object has a hidden parameter that contains a unique ID generated using CreateUUID. This name is also given to a locus within the object's profile group. When the layer is duplicated, the locus loses its name and the unique ID field is no longer unique. This can be problematic down the track.


    If the object could detect its creation, it could rectify this and generate a new unique ID. Thanks for any ideas.

  • Create New...