VvierA Posted August 23, 2013 Share Posted August 23, 2013 Hello everybody, I wrote a small Vectorscript that converts polygons to a custom path object (another plugin I made with the kind help of the members of this forum). The Vectorscript works perfectly with 2012 and it works with 2013 in the construction layer but it fails to work within the 'Annotations' of a sheet layer. Has anybody an idea? Any help or hint is kindly appreciated... ---------------------------------- PROCEDURE allesstempelkonverter; VAR objectH, newobjH :HANDLE; SObjectHandle :DYNARRAY [] OF HANDLE; numsel, zaehl :INTEGER; {in der ersten Schleife werden Handles zu allen gew?hlten Objekten verteilt} BEGIN objectH := FSActLayer; numsel := Count((SEL=TRUE)); ALLOCATE SObjectHandle[1..numsel]; zaehl := 1; WHILE (objectH <> NIL) DO BEGIN SObjectHandle[zaehl] := objectH; zaehl := zaehl+1; objectH := NextSObj(objectH); END; {message (numsel,' Z?hler ',zaehl);} {in der zweiten Schleife werden die Objekte umgewandelt} zaehl := 1; WHILE zaehl <= numsel DO BEGIN IF (GetType(SObjectHandle[zaehl]) = 3) OR {Pr?fung ob es ein Rectangle ist} (GetType(SObjectHandle[zaehl]) = 4) OR {Oval} (GetType(SObjectHandle[zaehl]) = 5) OR {Polygon} (GetType(SObjectHandle[zaehl]) = 6) OR {Bogen bzw. Kreis} (GetType(SObjectHandle[zaehl]) = 21) THEN BEGIN {Polyline} { SetPenFore(SObjectHandle[zaehl],45);} newobjH := CreateCustomObjectPath('db Allesstempel', SObjectHandle[zaehl], nil); END; zaehl := zaehl+1; END; END; run(allesstempelkonverter); ---------------------------------- Quote Link to comment
JBenghiat Posted August 23, 2013 Share Posted August 23, 2013 FSActLayer gets the handle to the first selected object in the active layer. That will give you, I believe, the viewport. The annotation objects aren't on a layer, they are in a viewport group. I don't have experience parsing annotation groups, but this may help: http://developer.vectorworks.net/index.php/VS:GetVPGroup You cal also check in what an object is contained via GetParent and check for object types via GetType. ForEachObjectInList should help you traverse all the selected objects in the annotation group or layer, looking only at selected objects. Instead of using Count to allocate your array, you may find useful keeping a manual counter and allocating as you go. -Josh Quote Link to comment
VvierA Posted September 24, 2013 Author Share Posted September 24, 2013 Thank you Josh. I tried to investigate, following your hints but I failed. As I understand I need a replacement for "FSActLayer" because this seems to return NIL if I select something inside a Design Layer viewport. Does anybody know a replacement for FSActLayer that works inside a Design Layer viewport? And does anybody know a routine to check if I'm inside a Design Layer viewport or not so that the script uses either FSActLayer or the 'other' command that works inside the viewport? Kind regards VvierA Quote Link to comment
VvierA Posted September 24, 2013 Author Share Posted September 24, 2013 Solved it with the help of Vectorlab (www.vectorlab.info). I found two subroutines to replace the FSActLayer. The subroutines work in both the construction layer and inside the annotations of a design layer viewport. I admit - I do not understand them completely but that's ok. VvierA FUNCTION H_ActContainer: HANDLE; BEGIN BeginContext; Locus(0, 0); H_ActContainer := GetParent(LNewObj); DelObject(LNewObj); EndContext(0); END; FUNCTION H_FSActContainer: HANDLE; VAR h : HANDLE; BEGIN h := FIn3D(H_ActContainer); WHILE (h <> NIL) & (Selected(h) = FALSE) DO IF Selected(h) THEN H_FSActContainer := h ELSE h := NextObj(h); H_FSActContainer := h; END; Quote Link to comment
Recommended Posts
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.