Jump to content
Developer Wiki and Function Reference Links ×

Vectorscript Editor: No inquiry command?


brudgers

Recommended Posts

It is in the current online documentation and in the help PDF.

While we're on the subject of vectorscript documentation and specifically selection criteria...

It would be helpful if there was a code example illustrating the use of Dynarray [] of handle to capture the results of selection.

If you search the vectorscript manual, the developer website, and the annotated function list you will not find an example showing how to handle criteria (or use)r selection of objects within vectorscript.

Lots of Dynarray [] of char but nothing that makes it clear how objects are manipulated by vectorscript.

Indeed in the online documentation the commands for sorting through a set of selected objects [FSObject, NSObj, etc.] are buried in "Document List Handling" and "document list handling" remains undefined.

I think many potential users of vectorscript would be helped if some examples were added to the "what can I do with vectorscript" thread.

Link to comment

Dynarrays are handled the same as arrays with the exeption that you need to allocate the number of items that it will hold while the program is executing. The size of arrays are predefined in the declaration of the variable while dynarrays have no size until you allocate its size in the program code.

VAR

totItems: INTEGER;

strArray: ARRAY[1..5] OF STRING;

strList: DYNARRAY[] OF STRING;

BEGIN

totItems:= 3;

ALLOCATE strList[1..totItems];

strList[1]:= 'first';

strList[2]:= 'second';

strList[3]:= 'third';

END;

I do agree that documentation on vectorscript is thin and some of us had the benefit to learn when the scripts were unlocked.

Link to comment

http://techboard.nemetschek.net/ubbthreads/ubbthreads.php?ubb=showflat&Number=113373#Post113373

Here one can find an example of how to load the handles of a group of selected objects into an array (both dynamic or otherwise) and how to step thru the array while acting on each object as one might see fit.

Document List Handling.... there are a number of lists in a document that exist or can be created. All the symbols in a folder, all the layers, all the classes and so forth are lists that already exist. All the objects that meet certain criteria comprise a list that a user can create. Break into one of these lists and the tools in 'List Handling' become your means of navigating therein.

Link to comment

I figured out how to do it after digging around the various documentation sources and piecing together the puzzle.

There was just a lot of dumb-tax I had to pay.

It's really hard to make use of the "criteria" command in the VS editor if you can't store handles.

I guess the main thought I have is that manipulating vectorworks objects is really a more relevant jumping off point for illustrating the capablilities of vectorscript than examples which change text in strings.

newStr:=Concat('A','sample','string');

ain't about to motivate anyone to learn vectorscript, and those who would care are off programming for the iphone.

Edited by brudgers
Link to comment
  • Vectorworks, Inc Employee

If you want the handles returned by criteria then look at ForEachObject();

It takes criteria as one parameter and a Function/Procedure.

The Function/Procedure used by FEO gets a single handle passed to the calling proc for each object matching the criteria. You can build you handle list inside of the proc.

Kevin

Link to comment

There was just a lot of dumb-tax I had to pay.

Indeed. Arrays are just arrays, regardless of what they contain: characters, handles, vectors, points, reals, integers, cats or dogs. You deal with them exactly the same way regardless.

I'm sure that in a Windows-only programming language they would all be entirely different to your pleasure and satisfaction.

Why don't you switch to the C++ SDK: I understand that NNA uses the Microsoft C++ as the basis.

No resource forks. No free steak knives, either.

Link to comment

It had nothing to do with not knowing what arrays are.

It was an issue of not quickly finding examples of how to manipulate objects using the query commands in the official documentation.

BTW since it breaks so many applications, maybe snow leopard should be "OSvi."

"s"

"t"

"a"

remember, you saw it here first.

Edited by brudgers
Link to comment
It had nothing to do with not knowing what arrays are.

OK. If you don't know what they are, I can't help you.

For the benefit of more knowledgeable communityboarders:

Objects can be put into an excplicit array with various methods; a criterion or a set of criteria is among those.

However, at least in my scripting, ForEachObject (and its variants), ie. implicit arrays, are usually sufficient. (NB: I do mainly objects, so Draughtsmen and -women are beyond my expertise.)

Setting a set of criteria for list handling is not always exactly easy. It appears that there is a pre-defined sequence, surely because of some sinister plot by the Insanely Great folks in Cupertino.

Thus, I prefer to first process the simplest possible list and whilst doing that, doing the more complex things.

Unfortunately, with programming skills limited to text-formatting tags in Internet forums, you'll never be able to do such complex things.

Link to comment
Objects can be put into an excplicit array with various methods; a criterion or a set of criteria is among those.

However, at least in my scripting, ForEachObject (and its variants), ie. implicit arrays, are usually sufficient.

Hi 'Kool-Aid' ;-) Good to have you back.

Implicit/explicit is a nice way to think of this. Thank-you.

Fact is, if selection or visibility state, layer options and traversal options are the only criteria then FEOinLayer is simpler. No need for an explicit array at all.

In the example I was referring to above (my version) the whole array exercise could be replaced with something along the lines of:

ForEachObjectInLayer(Change_it,2,0,2);

or possibly:

ForEachObject(Change_It,SEL=True);

If there's something more that needs to be done with the selection set (like collect, process and output data about the objects), then an explicit array can be useful.

Link to comment

Implicit/explicit is a nice way to think of this.

It is, isn't it! VW has implicit lists (criterion-based, among which the layer is a special case.)

In my mind I consider criteria via set theory. When processing a subset, I may (and usually do) devise further subsets.

UI-wise the most important set to deal with is the Selection (on the Active Layer.) Yes, I do subscribe to the Evil Plot by Jewish Bankers, Freemasons and other Bilderberg Illuminati based in Cupertino: object-verb syntax.

The free thinkers of the Gates-persuasion obviously prefer something else.

Link to comment

I admit placing a query within a loop to keep returning (previous value - last object) might appeal to some people, after all there has to be some means of identifying Templars.

The shortcoming in my mind (among an obvious many) is that it requires change_it to be a catchall for everything you want to do with whatever meets the criteria.

In debugging - and I admit that I need to do it - I have been finding it easier to comment out lines in the main loop than within the functions and subs.

Of course I'm a fan of pointers, but that's probably out of ignorance.

Link to comment

We'll tak a cup'o Kool-Aid yet, for auld lang syne!

Due to popular demand, even it is also for the benefit of Mr. B. of the Gatestown-cult:

The easy way to learn about and set up criteria (pl., s. is criterion; ref. datum-data, agendum-agenda etc.) in scripts is to use a database worksheet first.

For a fleeting moment, the VS expression is visible and even able to be copied and pasted.

Link to comment

Indeed.

And if a user is not really comfortable with worksheets, is no use to try scripting criteria.

To the new scripter:

Also useful is to create a "Custom modification" or "Custom selection" script and analyze it.

The criteria arguments are best learned in the "Worksheets" documentation integrating it with the "Vectorscript Guide > Search Criteria" for obj types and Search Criteria Tables.

Criteria -unregarded what most scripters think- is highly advanced stuff.

* you'll begin with criteria as VS-beginner

* abandon them thinking that you are smart enough to do better

* go back at a later "age" when you finally understand how powerful they are. When you finally understand them in detail.

They have limits and missing items, but few, few...

orso

Link to comment

OK. Let's illustrate these criteria a bit, as requested by a couple of board members.

The purpose is to have eg. loose furniture associated with the spaces they are in. In an office building or a school loose furniture is a major issue.

For the suppliers & site management (or removalists), getting the right stuff in the right place can also be an arduous task. Theoretically this even enables each item to have a sticker with the space number (and name & occupant's name etc.).

So, we process one layer at a time and search for particular PIOs that have a name and are visible. For each PIO we create a temporary polyline, a copy of its path, give the poly a temporary name and then search for items inside it, with a specific record attached, and write the space number in that record.

In large landscape projects this approach also may have merit.

Easy! Yes, criteria are powerful ? and very fast.

[font:Courier New]PROCEDURE ItemsByLocationInPIO;

{ ? Petri Sakkinen 1996?2009 (2009-09-02) - some sort of a lesser licence }

{ to use & modify as long as the author's ? is acknowledged and kept }

CONST

????pioName = 'name_of_pio';

????dataRecord = 'name_of_record';

????locationF = 'name_of_location_field';

????

VAR

????theLocation : HANDLE;

????locName, refName, layerName : STRING;

????dX, dY, rotA : REAL;

PROCEDURE GetItem (h : HANDLE);

BEGIN

????SETRFIELD(h, dataRecord, locationF, locName);

END;

PROCEDURE GetSpace (h : HANDLE);

BEGIN

????GETSYMLOC(h, dX, dY);

????rotA := GETSYMROT(h);

????theLocation := CREATEDUPLICATEOBJECT(GETCUSTOMOBJECTPATH(h), ACTLAYER);

????HROTATE(theLocation, 0, 0, rotA);

????HMOVE(theLocation, dX, dY);

????SETNAME(theLocation, 'Heart_of_Gold');

????locName := GETNAME(h);

????FOREACHOBJECT(GetItem, ((L=layerName) & (LOC='Heart_of_Gold') & (R in [dataRecord])));

????DELOBJECT(theLocation);

END;

BEGIN

????layerName := GETLNAME(ACTLAYER);

????FOREACHOBJECT(GetSpace, ((L=layerName) & (R in [pioName]) & NOT(N='none') & V));

END;

RUN(ItemsByLocationInPIO);

[/font]

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...