Julian Carr
-
Posts
320 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Articles
Marionette
Store
Posts posted by Julian Carr
-
-
The function GetObjectTags() returns a string array of all the tags attached to a class, layer or other object that supports tags (not to be confused with Data Tags). Once you have the string array, how can you extract each tag when you don't know the separator or quantity of strings? The separator is likely to be a line feed or carriage return, but could be different on each platform.
One way would be to keep extracting strings s[1], s[2], s[3], etc until there was an error, but that seems crude. Any ideas?
-
You cannot do this:
AlrtDialog: STRING;
because you are declaring a procedure as a string. Either delete that line or try this:
AlrtDialog2: STRING;
Either way it will work.
-
Two things wrong.
1. N should be an integer not a string.
2. AlrtDialog cannot be used as a string because it is a reserved word being a procedure.
- 1
-
You need to get the insertion point of the PIO using GetSymLoc() then add the internal offset within the PIO to that.
- 1
-
You could try :
PtInPoly(pX, pY : REAL; h : HANDLE):BOOLEAN; -
You cannot access the printer settings in Vectorscript. There may also be a physical limit on the page dimensions in the OS. At least that used to be the case.
-
This is what I use to get the page dimensions. Note it works on the active layer so you have to store the active layer name, switch to the layer you are querying, then back again on completion. Also note it is returning mm:
Procedure GetDrawingSizeRect2(VAR dx1, dy1, dx2, dy2 : REAL; VAR PageWdth, PageHght : INTEGER);
VAR
s1, s2 : STRING;
r1 : REAL;
BEGIN
IF NOT IsNewCustomObject(gPIOName) THEN BEGIN
s2 := GetLName(ActLayer);
s1 := GetLName(GetLayer(ghParm));
IF (s1 <> '') & (GetType(GetObject(s1)) = 31) THEN Layer(s1) { switch layers so that GDSR() measures active layer (for use with RIP command }
ELSE s1 := '';
END;
GetDrawingSizeRect(dx1, dy1, dx2, dy2);
r1 := GetLScale(ActLayer); { use this here instead of gLScale because GetDrawingSizeRect() is using the active layer, not the PIO layer }
IF s2 <> '' THEN Layer(s2);
PageWdth := Abs(dx2 - dx1) / r1 * 25.4 / gUPI; { page width in mm } { use gLScale here so that comparisons are in real world sizes, not scaled }
PageHght := Abs(dy2 - dy1) / r1 * 25.4 / gUPI; { page height in mm }
END;You can use SetDrawingRect() to set the page size, though you need to consider that the drawing size rectangle represents the printable area for the currently selected printer, not the actual page size. I have a routine that tries to match the drawing size rectangle to the metric or imperial page size. Here's part of it:
CONST
kPS1m = 148; { ISO Sizes including Super A3 }
kPS2m = 210;
kPS3m = 297;
kPS4m = 420;
kPS5m = 594;
kPS6m = 841;
kPS7m = 1189;
kPS8m = 707;
kPS9m = 1000;
kPS10m = 1414;
kPS11m = 330; { 13" Super A3 }
kPS12m = 483; { 19" Super A3 }kPS11i = 229; { 9" } { US Arch Sizes }
kPS12i = 305; { 12" }
kPS13i = 457; { 18" }
kPS14i = 610; { 24" }
kPS15i = 914; { 36" }
kPS16i = 1219; { 48" }kPS17i = 216; { 8.5" } { ASME Sizes }
kPS18i = 279; { 11" }
kPS19i = 432; { 17" }
kPS20i = 559; { 22" }
kPS21i = 864; { 34" }
kPS22i = 1118; { 44" }
CASE gPageFormat OF { if possible, set page size string from found page dimensions }
1: BEGIN { ISO }
IF ((PageWdth = kPS2m) & (PageHght = kPS1m)) | ((PageWdth = kPS1m) & (PageHght = kPS2m)) THEN PageSize := 'A5'
ELSE IF ((PageWdth = kPS3m) & (PageHght = kPS2m)) | ((PageWdth = kPS2m) & (PageHght = kPS3m)) THEN PageSize := 'A4'
ELSE IF ((PageWdth = kPS4m) & (PageHght = kPS3m)) | ((PageWdth = kPS3m) & (PageHght = kPS4m)) THEN PageSize := 'A3'
ELSE IF ((PageWdth = kPS5m) & (PageHght = kPS4m)) | ((PageWdth = kPS4m) & (PageHght = kPS5m)) THEN PageSize := 'A2'
ELSE IF ((PageWdth = kPS6m) & (PageHght = kPS5m)) | ((PageWdth = kPS5m) & (PageHght = kPS6m)) THEN PageSize := 'A1'
ELSE IF ((PageWdth = kPS7m) & (PageHght = kPS6m)) | ((PageWdth = kPS6m) & (PageHght = kPS7m)) THEN PageSize := 'A0'
ELSE IF ((PageWdth = kPS9m) & (PageHght = kPS8m)) | ((PageWdth = kPS8m) & (PageHght = kPS9m)) THEN PageSize := 'B1'
ELSE IF ((PageWdth = kPS10m) & (PageHght = kPS9m)) | ((PageWdth = kPS9m) & (PageHght = kPS10m)) THEN PageSize := 'B0'
ELSE IF ((PageWdth = kPS12m) & (PageHght = kPS11m)) | ((PageWdth = kPS11m) & (PageHght = kPS12m)) THEN PageSize := 'Super A3'
ELSE FlagCustom := True;
END;
2: BEGIN { US Arch }
IF ((PageWdth = kPS12i) & (PageHght = kPS11i)) | ((PageWdth = kPS11i) & (PageHght = kPS12i)) THEN PageSize := 'US Arch A'
ELSE IF ((PageWdth = kPS13i) & (PageHght = kPS12i)) | ((PageWdth = kPS12i) & (PageHght = kPS13i)) THEN PageSize := 'US Arch B'
ELSE IF ((PageWdth = kPS14i) & (PageHght = kPS13i)) | ((PageWdth = kPS13i) & (PageHght = kPS14i)) THEN PageSize := 'US Arch C'
ELSE IF ((PageWdth = kPS15i) & (PageHght = kPS14i)) | ((PageWdth = kPS14i) & (PageHght = kPS15i)) THEN PageSize := 'US Arch D'
ELSE IF ((PageWdth = kPS16i) & (PageHght = kPS15i)) | ((PageWdth = kPS15i) & (PageHght = kPS16i)) THEN PageSize := 'US Arch E'
ELSE FlagCustom := True;
END;
3: BEGIN { ASME }
IF ((PageWdth = kPS18i) & (PageHght = kPS17i)) | ((PageWdth = kPS17i) & (PageHght = kPS19i)) THEN PageSize := 'ASME A'
ELSE IF ((PageWdth = kPS19i) & (PageHght = kPS18i)) | ((PageWdth = kPS18i) & (PageHght = kPS19i)) THEN PageSize := 'ASME B'
ELSE IF ((PageWdth = kPS20i) & (PageHght = kPS19i)) | ((PageWdth = kPS19i) & (PageHght = kPS20i)) THEN PageSize := 'ASME C'
ELSE IF ((PageWdth = kPS21i) & (PageHght = kPS20i)) | ((PageWdth = kPS20i) & (PageHght = kPS21i)) THEN PageSize := 'ASME D'
ELSE IF ((PageWdth = kPS22i) & (PageHght = kPS21i)) | ((PageWdth = kPS21i) & (PageHght = kPS22i)) THEN PageSize := 'ASME E'
ELSE FlagCustom := True;
END;
END;
-
GetSymRot(ghParm) and IsObjectFlipped(ghParm) need to be used in combination to get the flip status. I doubt whether you can find something that will flip a symbol however.
-
To date I have only ever read this value and never tried to write to it. That said, this seems to work for toggling the setting on or off using Vectorscript:
SetPref(544, NOT GetPref(544));
Perhaps someone else with Python knowledge can spot something in your script.
-
Try GetPref(544).
-
Anyone have a lazy script that will convert an upper case string to title caps or even just lower case? Just trying to avoid reinventing the wheel.
TIA,
Julian
-
In my experience, user input interruptions in Vectorscript are very very limited and often unreliable, and I suspect it would be the same in Python. You really need to go to the SDK for things like this.
- 2
-
While is seems logical to try and emulate how you work with the mouse to select objects then edit them in some way, if you want to get into scripting then you'll find it much easier to work with handles. And the single most useful call for this is ForEachObject(), because it uses criteria to choose what gets processed. This can be object type, class, layer, colour, selection state, etc. Using FEO would look something like this:
Procedure T;
VAR
grNewLen : REAL;Procedure DoIt(h1 : HANDLE);
VAR
rCenterX, rCenterY : REAL;
rScaleFactor : REAL;
rExistLen : REAL;
BEGIN
HCenter(h1, rCenterX, rCenterY);
rExistLen := HLength(h1);
rScaleFactor := (rExistLen + grNewLen) / rExistLen;
HScale2D(h1, rCenterX, rCenterY, rScaleFactor, rScaleFactor, False);
END;BEGIN { main }
grNewLen := RealDialog('New Length?', '2');
IF NOT DidCancel THEN ForEachObject(DoIt, (T = Line));
Redraw;
END;
Run(T); -
Pat is right. Scaling the line using HScale2D is the way to go and it is easy enough:
Procedure T;
VAR
h1 : HANDLE;
rCenterX, rCenterY : REAL;
rScaleFactor : REAL;
rExistLen, rNewLen : REAL;
BEGIN
h1 := FSActLayer;
HCenter(h1, rCenterX, rCenterY);
rExistLen := HLength(h1);
rNewLen := RealDialog('New Length?', Concat(rExistLen));
rScaleFactor := rNewLen / rExistLen;
HScale2D(h1, rCenterX, rCenterY, rScaleFactor, rScaleFactor, False);
Redraw;
END;
Run(T); -
Yes, in an old PIO. It still works in 2020. Here is the code:
Function GetColourIndex(CurrentIndex : INTEGER) : INTEGER;
VAR
DialogID, DlogResult : INTEGER;Function Define_Dialog: INTEGER;
VAR
dialogID : INTEGER;
BEGIN
dialogID := CreateLayout('Choose Colour', False, 'OK', 'Cancel');
CreateGroupBox(dialogID, 4, '', False);
CreateControl(dialogID, 5, 2,'',0);
SetFirstLayoutItem(dialogID, 4);
SetBelowItem(dialogID, 4, 5, 5, 0);
Define_Dialog := dialogID;
END;Procedure Drive_Dialog(VAR item:LONGINT; data:LONGINT);
VAR
red, green, blue : LONGINT;
BEGIN
CASE item OF
SetupDialogC: BEGIN
ColorIndexToRGB(CurrentIndex, red, green, blue);
SetColorButton(DialogID, 5, red, green, blue);
END;
1: BEGIN
GetColorButton(DialogID, 5, red, green, blue);
RGBToColorIndex(red, green, blue, GetColourIndex);
END;
2: GetColourIndex := CurrentIndex;
END;
END;BEGIN
DialogID := Define_Dialog;
IF VerifyLayout(DialogID) THEN DlogResult := RunLayoutDialog(DialogID, Drive_Dialog);
END; -
There is no official way to do it, however if you used CreateImageControl2() to insert the image as the first item in the dialog, you could probably then use SetBelowItem() with a large negative Y value to place the next item over the image and subsequent items below that. You will need to create a VWR file to store the image, which is simply a zip file of the image or images (without a parent folder), which you then just change the file suffix from .zip to .vwr. If your zip/vwr file was called MyImages.vwr, and the image in there was called image1.png (use png images), then the call to place the image would be something like this:
CreateImageControl2 (Dialog1, ItemID, 500, 400, 'MyImages/image1.png');
The VWR file lives in the Plug-ins folder and 500/400 is the pixel size you want the image to appear in the dialog. Just make sure to preserve the image proportions. For example, this would work if the actual image was 1000 x 800 pixels, or 1500 x 1200, etc.
-
SetWallCornerHeights() might work.
- 1
-
Thanks a lot Pat and Ray. I cobbled something together from what you sent.
-
Anyone have a script handy that will export a list containing sheet layer names and numbers?
TIA.
-
I guess the first question is why does your PIO need to reset when the zoom level changes? Generally this should not be necessary. Ignoring that for the moment, if this were possible it could only work in an event enabled PIO using SetObjPropVS(). I don't have the full list at hand, but this is the function that allows PIOs to reset if there are layer scale or layer elevation changes, for example.
-
I don't recall a script, but you can just select all the sheets in the Nav palette, right click, choose Edit, then change the DPI there. Only takes a few seconds.
-
This works for me:
Procedure T;
VAR
BeamHandle : HANDLE;
BEGIN
BeamHandle:=CreateCustomObjectN('Wide Flange - 3D',0,0,0,FALSE);
SetRField(BeamHandle,'Wide Flange - 3D','__series_2', 'AISC (Metric)');
SetRField(BeamHandle,'Wide Flange - 3D','__size_2', 'W200 x 22.3');
SetRField(BeamHandle,'Wide Flange - 3D','Length', '3000mm');
SetRField(BeamHandle,'Wide Flange - 3D','__current_series', '2');
SetRField(BeamHandle,'Wide Flange - 3D','__current_size_2', 'W200 x 22.3');
Set3DRot(BeamHandle,0,45,0,0,0);
ResetObject(BeamHandle);
END;
Run(T);- 1
-
This will at least explode the object for you:
SymbolToGroup(FSActLayer, 1);
-
Thanks Josh. I worked out another way to achieve the end goal.
Determining String Array Quantity
in Vectorscript
Posted
Thanks Josh. This enabled me to discover that the array size is fixed at 20, which means you can only apply a maximum of 20 tags to an object.