Jump to content
Developer Wiki and Function Reference Links ×

Turning on Classes in ViewPort Script.


Assembly

Recommended Posts

Trying to script view ports.

I have managed to create a view port and turn on the current active layer with this snip:

ShowLayer:=0;

hLayerCurrent:=ActLayer;

hLayer:=CreateLayer(LayerNameString,2);

hVP:=CreateVP(hLayer);

result:=SetVPLayerVisibility(hVP,hLayerCurrent, ShowLayer);

How do I cycle the full list of layers to turn on?

How do I cycle the full list of classes to turn on?.

Edited by Assembly
Link to comment

Sort the Function Reference by Class.

The Layers section gives you all the information on layer. FLayer will give you a handle to the first layer.

Document List Handling section gives you NextLayer and PrevLayer

Classes gives you ClassNum that returns the total number of classes in the file. ClassList(X) will give you the name of the class that is number X in the drawing.

You will need to create a loop for Layers and another for Classes and manually go through and get all the names you need.

Link to comment
  • 1 month later...

I just had a dig around some ancient code which may be useful

I used two procedures for manipulating VP classes and layers with a range of options including wildcarding names.

Restricted to maximum 200 classes and 200 layers.

procedure example;

{By Bill Wood 2010}

Const

{Viewport layer and class visibility}

kVISIBLE = 0;

kINVISIBLE = 1;

kGREYED = 2;

{Viewport Class/Layer build}

kNOCHECK = 1;

kINCLUSION = 2;

kEXCLUSION = 3;

{Layer names}

kGRIDLYR = 'Grid layer';

kSHEDLYR = 'Build layer';

Var

vpH : HANDLE;

classnames,layernames : array[1..200] of STRING;

classcnt : INTEGER;

procedure setvpclassvis(vportH : HANDLE; classnames : array[1..200] of STRING; classcnt,genmethod,visibility : INTEGER; forceothersalternate : BOOLEAN);

Label 100,150;

Var

i,j,altvisible : INTEGER;

classfnd,btest : BOOLEAN;

classtest : array[1..200] of BOOLEAN;

classstr : array[1..200] of STRING;

starpos : INTEGER;

begin

case visibility of

kINVISIBLE: altvisible := kVISIBLE;

kVISIBLE: altvisible := kINVISIBLE;

end;

case genmethod of

kNOCHECK: begin

for i := 1 to classcnt do btest := setvpclassvisibility(vportH,classnames,visibility);

end;

kINCLUSION: begin

for i := 1 to classcnt do begin

starpos := pos('*',classnames);

classtest := (starpos <> 0);

if classtest then begin

if (starpos = 1) then classstr := copy(classnames,2,len(classnames)-1)

else classstr := copy(classnames,1,starpos-1);

end

else classstr := classnames;

end;

for i := 1 to classnum do begin

classfnd := FALSE;

for j := 1 to classcnt do begin

if classtest[j] then classfnd := (pos(classstr[j],classlist(i)) <> 0)

else classfnd := (classstr[j] = classlist(i));

if classfnd then goto 100;

end;

100: if classfnd then btest := setvpclassvisibility(vportH,classlist(i),visibility)

else if forceothersalternate then btest := setvpclassvisibility(vportH,classlist(i),altvisible);

end;

end;

kEXCLUSION: begin

for i := 1 to classcnt do begin

starpos := pos('*',classnames);

classtest := (starpos <> 0);

if classtest then begin

if (starpos = 1) then classstr := copy(classnames,2,len(classnames)-1)

else classstr := copy(classnames,1,starpos-1);

end

else classstr := classnames;

end;

for i := 1 to classnum do begin

classfnd := FALSE;

for j := 1 to classcnt do begin

if classtest[j] then classfnd := (pos(classstr[j],classlist(i)) <> 0)

else classfnd := (classstr[j] = classlist(i));

if classfnd then goto 150;

end;

150: if classfnd then btest := setvpclassvisibility(vportH,classlist(i),visibility)

else if forceothersalternate then btest := setvpclassvisibility(vportH,classlist(i),altvisible);

end;

end;

end;

end; {setvpclassvis}

procedure setvplayervis(vportH : HANDLE; layernames : array[1..200] of STRING; lyrcnt,genmethod ,visibility : INTEGER; forceothersalternate : BOOLEAN);

Label 100,150;

Var

i,j,altvisible : INTEGER;

layerfnd,btest : BOOLEAN;

lyrH : HANDLE;

lyrname : STRING;

begin

case visibility of

kINVISIBLE: altvisible := kVISIBLE;

kVISIBLE: altvisible := kINVISIBLE;

end;

case genmethod of

kNOCHECK: begin

for i := 1 to lyrcnt do btest := setvplayervisibility(vportH,getlayerbyname(layernames),visibility);

end;

kINCLUSION: begin

lyrH := flayer;

while (lyrH <> NIL) do begin

layerfnd := FALSE;

lyrname := getlname(lyrH);

for j := 1 to lyrcnt do begin

if (layernames[j] = lyrname) then begin

layerfnd := TRUE;

goto 100;

end;

end;

100: if layerfnd then btest := setvplayervisibility(vportH,lyrH,visibility)

else if forceothersalternate then btest := setvplayervisibility(vportH,lyrH,altvisible);

lyrH := nextlayer(lyrH);

end;

end;

kEXCLUSION: begin

lyrH := flayer;

while (lyrH <> NIL) do begin

layerfnd := FALSE;

lyrname := getlname(lyrH);

for j := 1 to lyrcnt do begin

if NOT (layernames = lyrname) then begin

layerfnd := TRUE;

goto 150;

end;

end;

150: if layerfnd then btest := setvplayervisibility(vportH,lyrH,visibility)

else if forceothersalternate then btest := setvplayervisibility(vportH,lyrH,altvisible);

lyrH := nextlayer(lyrH);

end;

end;

end;

end; {setvplayervis}

begin

{create viewport first}

layernames[1] := kGRIDLYR;

layernames[2] := kSHEDLYR;

setvplayervis(vpH,layernames,2,kNOCHECK,kVISIBLE,FALSE);

classnames[1] := 'Concrete-Panel*';

classnames[2] := 'Cladding*';

classnames[3] := 'Flashing*';

setvpclassvis(vpH,classnames,3,kEXCLUSION,kINVISIBLE,TRUE);

{Alternatively}

classcnt := 1;

classnames[classcnt] := 'Colour*';

classcnt := classcnt + 1;

classnames[classcnt] := 'Purlin Bay-Wall-A1:A*';

setvpclassvis(vpH,classnames,classcnt,kINCLUSION,kVISIBLE,FALSE);

end;

run(example);

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...