josue Corona Posted October 10, 2019 Share Posted October 10, 2019 If (currentCL:=Active;) mean that a certain object you make will be the current class selected, what is the script that makes an object to a certain class. Is because I have a script that makes frames , when it always makes them It always uses the current class (activated) I wanted to chose the class that I made which is Aluminum . To represent metal . Thanks Quote Link to comment
Peter Vandewalle Posted October 10, 2019 Share Posted October 10, 2019 Can you send a larger par tof the script? It's pretty hard to answer this. Quote Link to comment
josue Corona Posted October 10, 2019 Author Share Posted October 10, 2019 BEGIN {MOTHER PROG} PushAttrs; TF:=GetCustomObjectInfo(ObjName,ObjH,RecH,WallH); CurrentCL:=ActiveClass; FillBack(256); FillFore(257); FillPat(1); PenPatN(2); PenSize(6); PenBack(256); PenFore(257); PenPatN(2); { Visabilities set based on screen type } Quote Link to comment
josue Corona Posted October 10, 2019 Author Share Posted October 10, 2019 Am I correct that CurentCl;=ActiveClass; make your object become the current layer? Quote Link to comment
Peter Vandewalle Posted October 10, 2019 Share Posted October 10, 2019 NameClass('classname'); will make that class active. http://developer.vectorworks.net/index.php/VS:NameClass You might want to add PushAttrs; at the beginning of the script and PopAttrs; at the end to avoid changing the active class. sClassName := GetClass(ObjH); Will get you the classname of the current object. http://developer.vectorworks.net/index.php/VS:GetClass Quote Link to comment
Pat Stanford Posted October 10, 2019 Share Posted October 10, 2019 For an object that already exists you need to get a handle to the object and use SetClass or SetClassN. Quote Link to comment
josue Corona Posted October 10, 2019 Author Share Posted October 10, 2019 In my script that I change do you know what this means: FillBack(256); FillFore(257); FillPat(1); PenPatN(2); PenSize(6); PenBack(256); PenFore(257); PenPatN(2); Quote Link to comment
josue Corona Posted October 10, 2019 Author Share Posted October 10, 2019 I set the script to SetClass (FSActLayer, 'Aluminum'); It works it changes the object to new class but it won't change the color of the object when I try changing it into the class settings. Quote Link to comment
Pat Stanford Posted October 10, 2019 Share Posted October 10, 2019 The FillBack, FillFore, etc. are setting the defaults for the document. Any new object drawn will use those attributes. It sounds like you actually want to set all of the attributes to be ByClass so that when you change the class of the object the attributes will change also. Check out the SetLSByClass (and all of the other ByClass functions) to set the attributes by class. If you use the offline function reference, you have the option to "View By Class" at the upper left. Then check out the section title Object Attributes to see all of the functions that can be used to set object attributes. The off-line function reference is in the VW application folder VWHelp:Script Reference:ScriptFunctionReference.html Quote Link to comment
josue Corona Posted October 10, 2019 Author Share Posted October 10, 2019 If I put the whole script would you let me know what part of the script is controlling the color of the object ? Basically my object is a Frame with thin rectangle on top , the rectangle on top I was able to change the color in the script but the frame it always stays gray? Quote Link to comment
josue Corona Posted October 10, 2019 Author Share Posted October 10, 2019 Another thing to point, in this script the frame has 2 options, one option is aluminum frame, second is wood frame, when I change to wood frame it turns into brown, then when I change it to aluminum it turns gray Quote Link to comment
josue Corona Posted October 10, 2019 Author Share Posted October 10, 2019 Its good that turns gray for aluminum look alike color but its not a class layers , (I think) Quote Link to comment
Pat Stanford Posted October 10, 2019 Share Posted October 10, 2019 If you can share the script someone will be glad to look at it. I will when I can, but I am leaving on a trip later today. Quote Link to comment
josue Corona Posted October 10, 2019 Author Share Posted October 10, 2019 Procedure Flat; VAR TF :BOOLEAN; i,k,COUNT :INTEGER; cRed,cGrn,cBlu :LONGINT; BMW,BMH,BMWperim,BMHperim,CMW,CML,CMH,TEMP,TEMPX,TEMPY,CTX,CTY,SJUMP,TJUMPSEAM,TJUMP,NXTOGGLE,NXTOGGLESEAM,RUNNINGFT,TOTALAREA,SMW,SMH,SOverAllW :REAL; ObjName,CMCLASS,CurrentCL :STRING; JUMP :POINT; ObjH,RecH,WallH,THandle,TempH :HANDLE; SHandle : ARRAY[1..501] OF HANDLE; BEGIN {MOTHER PROG} PushAttrs; TF:=GetCustomObjectInfo(ObjName,ObjH,RecH,WallH); CurrentCl:=ActiveClass; FillBack(256); FillFore(257); FillPat(1); PenPatN(2); PenSize(6); PenBack(256); PenFore(257); PenPatN(2); { Visabilities set based on screen type } IF PBuildMat = 'Custom' THEN BEGIN SetParameterVisibility(ObjH,'CustBMW',True); SetParameterVisibility(ObjH,'CustBMH',True); END ELSE BEGIN SetParameterVisibility(ObjH,'CustBMW',False); SetParameterVisibility(ObjH,'CustBMH',False); END; IF PCoverMat = 'Custom' THEN BEGIN SetParameterVisibility(ObjH,'CustCoverMatW',True); SetParameterVisibility(ObjH,'CustCoverMatL',True); SetParameterVisibility(ObjH,'CustCoverMatH',True); END ELSE BEGIN SetParameterVisibility(ObjH,'CustCoverMatW',False); SetParameterVisibility(ObjH,'CustCoverMatL',False); SetParameterVisibility(ObjH,'CustCoverMatH',False); END; IF PBuildMat = 'wood 1 x 3' THEN BEGIN BMW:=2.625"; BMH:=.75"; END; IF PBuildMat = 'poplar 1 x 3' THEN BEGIN BMW:=2.625"; BMH:=.75"; END; IF PBuildMat = 'plywood 1 x 3' THEN BEGIN BMW:=2.625"; BMH:=.78125"; END; IF PBuildMat = 'wood 1 x 4' THEN BEGIN BMW:=3.5"; BMH:=.75"; END; IF PBuildMat = 'wood 2 x 4' THEN BEGIN BMW:=3.5"; BMH:=1.5"; END; IF PBuildMat = 'metal 1 x 1' THEN BEGIN BMW:=1"; BMH:=1"; END; IF PBuildMat = 'metal 1.25 x 1.25' THEN BEGIN BMW:=1.25"; BMH:=1.25"; END; IF PBuildMat = 'metal 1.25 x 2.5' THEN BEGIN BMW:=2.5"; BMH:=1.25"; END; IF PBuildMat = 'Custom' THEN BEGIN BMW:=PCustBMW; BMH:=PCustBMH; END; IF PBuildMatO = 'Laying down' THEN BEGIN BMWperim:=BMW; BMHperim:=BMH; END ELSE BEGIN BMWperim:=BMH; BMHperim:=BMW; END; IF (PBuildMat = 'wood 1 x 3')|(PBuildMat = 'wood 1 x 4')|(PBuildMat = 'wood 2 x 4') THEN BEGIN FillFore(46529,34664,22800); {0=black} FillBack(46529,34664,22800); {65535=white} END ELSE BEGIN FillFore(52428,52428,52428); {0=black} FillBack(52428,52428,52428); {65535=white} END; IF PBuildCorner = 'Standard flat construction' THEN BEGIN CTX:=0; CTY:=0; END; IF PBuildCorner = 'Toggles & Rails same dimension' THEN BEGIN CTX:=BMWperim; CTY:=BMWperim; END; IF PBuildCorner = 'Mitered corners' THEN BEGIN CTX:=BMWperim; CTY:=0; END; IF PCoverMat = 'None' THEN BEGIN CMW:=PFlatW; CML:=PFlatH; CMH:=0; END; IF PCoverMat = 'Luan 4''x8''' THEN BEGIN CMW:=4'; CML:=8'; CMH:=.1875"; CMCLASS:='PP- Scenic Flat Covering LUAN'; cRed:=36175; cGrn:=26213; cBlu:=16253; END; IF PCoverMat = 'Luan 4''x10''' THEN BEGIN CMW:=4'; CML:=10'; CMH:=.1875"; CMCLASS:='PP- Scenic Flat Covering LUAN'; cRed:=36175; cGrn:=26213; cBlu:=16253; END; IF PCoverMat = 'Luan covering' THEN BEGIN CMW:=PFlatW; CML:=PFlatH; CMH:=.1875"; CMCLASS:='PP- Scenic Flat Covering LUAN'; cRed:=36175; cGrn:=26213; cBlu:=16253; END; IF PCoverMat = 'Fabric covering' THEN BEGIN CMW:=PFlatW; CML:=PFlatH; CMH:=.0625"; CMCLASS:='PP- Scenic Flat Covering FABRIC'; cRed:=65535; cGrn:=65535; cBlu:=65535; END; IF PCoverMat = 'Custom' THEN BEGIN CMW:=PCustCoverMatW; CML:=PCustCoverMatL; CMH:=PCustCoverMatH; CMCLASS:='PP- Scenic Flat Covering CUSTOM'; cRed:=65535; cGrn:=65535; cBlu:=65535; END; IF (PCoverMat = 'Custom') & (CMW>PFlatW) THEN CMW:=PFlatW; IF (PCoverMat = 'Custom') & (CML>PFlatH) THEN CML:=PFlatH; { C R E A T I N G T H E C L A S S F O R T H E C O V E R I N G M A T E R I A L } k:=1; TF:=True; WHILE k<=ClassNum DO BEGIN IF ClassList(k)=CMClASS THEN TF:=False; k:=k+1; END; IF TF=True THEN BEGIN NameClass(CMClass); SetClLSN(CMClass,2); {Line style} SetClPenFore(CMClass,0,0,0); {Pen fore color} SetClPenBack(CMClass,0,0,0); {Pen back color} SetClFPat(CMClass,2); {Fill pattern} SetClFillFore(CMClass,cRed,cGrn,cBlu); {Fill fore color} SetClFillBack(CMClass,cRed,cGrn,cBlu); {Fill back color} SetClUseGraphic(CMClass,TRUE); {Use gfx attri at creation} SetClLW(CMClass,180mm); {Line weight} END; NameClass(CurrentCL); IF CMW >= PFlatW THEN BEGIN SetParameterVisibility(ObjH,'SSpac',True); SetParameterVisibility(ObjH,'SSpacMax',True); END ELSE BEGIN SetParameterVisibility(ObjH,'SSpac',False); SetParameterVisibility(ObjH,'SSpacMax',False); END; ClosePoly; BeginXtrd(0,-BMHperim); {BOTTOM RAIL} Poly(0+CTY,0, PFlatW-CTY,0, PFLATW-CTX,BMWperim, 0+CTX,BMWperim); {TOP RAIL} Poly(0+CTY,PFlatH, PFlatW-CTY,PFlatH, PFLATW-CTX,PFlatH-BMWperim, 0+CTX,PFlatH-BMWperim); {LEFT STILE} Poly(0,BMWperim-CTX, 0,PFlatH-BMWperim+CTX, BMWperim,PFlatH-BMWperim+CTY, BMWperim,BMWperim-CTY); {RIGHT STILE} Poly(PFlatW,BMWperim-CTX, PFlatW,PFlatH-BMWperim+CTX, PFlatW-BMWperim,PFlatH-BMWperim+CTY, PFlatW-BMWperim,BMWperim-CTY); EndXtrd; RUNNINGFT:=2*((PFlatW-CTY)-(0+CTY))+2*((PFlatH-BMWperim+CTX)-(BMWperim-CTX)); { D R A W I N G T H E I N T E R I O R S T I L E S } IF PStileStyle <> 'Laying down' THEN BEGIN SMW:=BMH; SMH:=BMW; END ELSE BEGIN SMW:=BMW; SMH:=BMH; END; IF PStileStyle = 'Standing up - double' THEN SOverAllW:=SMW*2 ELSE SOverAllW:=SMW; IF CMW < PFlatW THEN SJUMP:=CMW ELSE {Stile spacing is based on Cover Material width} IF PSSpac = 'Evenly' THEN IF Round(PFlatW/PSSpacMax)=(PFlatW/PSSpacMax) THEN SJUMP:=PFlatW/(PFlatW/PSSpacMax) ELSE SJUMP:=PFlatW/(Trunc(PFlatW/PSSpacMax)+1) ELSE SJUMP:= PSSpacMax; JUMP.x:=SJUMP; i:=0; WHILE JUMP.x<PFlatW DO BEGIN IF (JUMP.x+(.5*SOverAllW)) > (PFlatW-BMWperim) THEN JUMP.x:=PFlatW-BMWperim-(.5*SOverAllW); IF PStileStyle = 'Standing up - double' THEN BEGIN { CREATING A DOUBLE STILE } BeginXtrd(0,-SMH); {INTERNAL STILE1} Poly(Jump.x-(SMW),BMWperim, Jump.x-(SMW),PFlatH-BMWperim, Jump.x,PFlatH-BMWperim, Jump.x,BMWperim); EndXtrd; i:=i+1; SHandle:=LNewObj; BeginXtrd(0,-SMH); {INTERNAL STILE2} Poly(Jump.x,BMWperim, Jump.x,PFlatH-BMWperim, Jump.x+(SMW),PFlatH-BMWperim, Jump.x+(SMW),BMWperim); EndXtrd; i:=i+1; SHandle:=LNewObj; RUNNINGFT:=RUNNINGFT+(PFlatH-BMWperim*2)*2; END ELSE BEGIN { CREATING A SINGLE STILE } BeginXtrd(0,-SMH); {INTERNAL STILE} Poly(Jump.x-(.5*SMW),BMWperim, Jump.x-(.5*SMW),PFlatH-BMWperim, Jump.x+(.5*SMW),PFlatH-BMWperim, Jump.x+(.5*SMW),BMWperim); EndXtrd; RUNNINGFT:=RUNNINGFT+(PFlatH-BMWperim*2); i:=i+1; SHandle:=LNewObj; END; JUMP.x:=JUMP.x+SJUMP; END; { D R A W I N G T H E T O G G L E S } IF CML <= PFLATH THEN TJUMPSEAM:=CML ELSE TJUMPSEAM:=PFLATH; IF PTSpac = 'Evenly' THEN IF Round(TJUMPSEAM/PTSpacMax)=(TJUMPSEAM/PTSpacMax) THEN TJUMP:=PTSpacMax ELSE TJUMP:=TJUMPSEAM/(Trunc(TJUMPSEAM/PTSpacMax)+1) ELSE TJUMP:= PTSpacMax; BeginXtrd(0,-BMHperim); {TOGGLE} Poly(BMWperim,BMWperim, PFlatW-BMWperim,BMWperim, PFlatW-BMWperim,2*BMWperim, BMWperim,2*BMWperim); EndXtrd; THandle:=LNewObj; FOR Count:=i DOWNTO 1 DO BEGIN DSelectAll; SetSelect(SHandle[Count]); DUPLICATE(0,0); TEMP:=SUBTRACTSOLID(THandle,SHandle[Count],THandle); END; Move3DObj(THandle,0,-1.5*BMWperim,0); IF TJump<=TJumpseam-BMWperim*1.5 THEN Jump.y:=TJump ELSE Jump.y:=TJumpseam; NXTOGGLE:=TJump; NXTOGGLESEAM:=TJumpseam; Temp:=0; WHILE Jump.y<=(PFlatH-BMWperim*1.5) DO BEGIN IF Jump.y=NXTOGGLE THEN BEGIN {DUPLICATING A REGULAR TOGGLE} IF Jump.y > (NXTOGGLESEAM-BMWperim*1.5) THEN Temp:=(NXTOGGLESEAM-BMWperim*1.5)-Jump.y; IF Jump.y < (NXTOGGLESEAM-TJumpseam+BMWperim*1.5) THEN Temp:=(NXTOGGLESEAM-TJumpseam+BMWperim*1.5)-Jump.y; TempH:=HDuplicate(THandle,0,0); Move3DObj(TempH,0,Jump.y+Temp,0); RUNNINGFT:=RUNNINGFT+(PFlatW-BMWperim*2); IF BMHperim = BMH THEN RUNNINGFT:=RUNNINGFT-i*BMWperim; Temp:=0; NXTOGGLE:=NXTOGGLE+TJump; END ELSE BEGIN {DUPLICATING A TOGGLE ON A SEAM} IF PBuildMatO <> 'Laying down' THEN BEGIN TempH:=HDuplicate(THandle,0,0); Move3DObj(TempH,0,Jump.y-BMWperim*.5,0); TempH:=HDuplicate(THandle,0,0); Move3DObj(TempH,0,Jump.y+BMWperim*.5,0); RUNNINGFT:=RUNNINGFT+2*(PFlatW-BMWperim*2); IF BMHperim = BMH THEN RUNNINGFT:=RUNNINGFT-2*(i*BMWperim); END ELSE BEGIN TempH:=HDuplicate(THandle,0,0); Move3DObj(TempH,0,Jump.y,0); RUNNINGFT:=RUNNINGFT+(PFlatW-BMWperim*2); IF BMHperim = BMH THEN RUNNINGFT:=RUNNINGFT-(i*BMWperim); END; NXTOGGLESEAM:=NXTOGGLESEAM+TJumpseam; END; IF NXTOGGLE<NXTOGGLESEAM THEN Jump.y:=NXTOGGLE ELSE Jump.y:=NXTOGGLESEAM; IF NXTOGGLE = NXTOGGLESEAM THEN NXTOGGLE:=NXTOGGLE+TJump; END; DelObject(THandle); SetRField(ObjH,GetName(RecH),'Summary1',Concat(Num2StrF(RUNNINGFT),' of linear material')); { C O V E R I N G M A T E R I A L } Jump.x:=0; Jump.y:=0; TEMPx:=0; TEMPy:=0; TOTALAREA:=0; IF PCoverMat <> 'None' THEN BEGIN NameClass(CMCLASS); WHILE Jump.x < PFlatW DO BEGIN IF Jump.x + CMW <= PFlatW THEN TEMPx:=CMW ELSE TEMPx:= PFlatW-Jump.x; IF Jump.y + CML <= PFlatH THEN TEMPy:=CML ELSE TEMPy:= PFlatH-Jump.y; BeginXtrd(0,CMH); {Covering material} Poly(Jump.x,Jump.y, Jump.x+TEMPx,Jump.y, Jump.x+TEMPx,Jump.y+TEMPy, Jump.x,Jump.y+TEMPy); EndXtrd; SetClass(LNewObj,CMClass); TOTALAREA:=TOTALAREA+OBJAREA(LNEWOBJ); IF Jump.y+TEMPy < PFlatH THEN BEGIN Jump.y:=Jump.y+TEMPy; END ELSE BEGIN Jump.x:=Jump.x+TEMPx; Jump.y:=0; END; TEMPx:=0; TEMPy:=0; END; SetRField(ObjH,GetName(RecH),'Summary2',Concat(Num2Str(2,TOTALAREA),' sq.ft. of covering material')); END; NameClass(CurrentCL); PopAttrs; END; {MOTHER PROG} RUN (Flat); Quote Link to comment
Pat Stanford Posted October 10, 2019 Share Posted October 10, 2019 PushAttrs; TF:=GetCustomObjectInfo(ObjName,ObjH,RecH,WallH); CurrentCl:=ActiveClass; FillBack(256); FillFore(257); FillPat(1); PenPatN(2); PenSize(6); PenBack(256); PenFore(257); PenPatN(2); The above lines store the old attributes settings (Push Attrs) and set the attributes that objects drawn during the execution of the script will use. The PopAttrs at the end of the script returns the settings to what they were before the script was run. If you really want to use the class attributes, everything from FillBack to PenPatN could be deleted. IF (PBuildMat = 'wood 1 x 3')|(PBuildMat = 'wood 1 x 4')|(PBuildMat = 'wood 2 x 4') THEN BEGIN FillFore(46529,34664,22800); {0=black} FillBack(46529,34664,22800); {65535=white} END ELSE BEGIN FillFore(52428,52428,52428); {0=black} FillBack(52428,52428,52428); {65535=white} END; These lines control the color that the fill is set to. If you want to use the class attributes you could eliminate the IF/Else and just use SetFillColorByClass; IF TF=True THEN BEGIN NameClass(CMClass); SetClLSN(CMClass,2); {Line style} SetClPenFore(CMClass,0,0,0); {Pen fore color} SetClPenBack(CMClass,0,0,0); {Pen back color} SetClFPat(CMClass,2); {Fill pattern} SetClFillFore(CMClass,cRed,cGrn,cBlu); {Fill fore color} SetClFillBack(CMClass,cRed,cGrn,cBlu); {Fill back color} SetClUseGraphic(CMClass,TRUE); {Use gfx attri at creation} SetClLW(CMClass,180mm); {Line weight} END; This section sets the attributes of the class based on the RGB values you specified earlier in the script. But it does not tell the object you are drawing to use the class attributes. But the next line switches the active class so that the class you set the attributes for is not active. So this code is not really doing much for you. I don't know exactly what you are trying to accomplish, but if you want to use the class attributes, you need to change the first block to make all the attributes ByClass instead of the settings that are shown. Then when you change the class the object will use the class settings. And if you do this you can simplify the script to remove all of the RGB setting code as that will all be done in the class setup. If you want to manually set the attributes as you are doing that is fine, but you can't manually set the attributes and then also expect them to use the class settings. It is one or the other. If you are using attributes by class you probably don't want to change the class attributes in the script that is drawing the objects as everything else in the file using those class attributes will also change. You will probably need to have a wood class and an aluminum class and set the object in the correct one rather than setting the attributes manually. Quote Link to comment
josue Corona Posted October 10, 2019 Author Share Posted October 10, 2019 Thank you 😄 I will try to make those changes . Just to point out, this script I did not make it, and I am still learning how to script. Quote Link to comment
Pat Stanford Posted October 10, 2019 Share Posted October 10, 2019 8 minutes ago, josue Corona said: Thank you 😄 I will try to make those changes . Just to point out, this script I did not make it, and I am still learning how to script. I kind of guessed that might be the case. Keep asking and we will keep trying to help you out. But response times might be longer than what you got this morning. 😉 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.