michaelk Posted September 3, 2019 Share Posted September 3, 2019 I have a script I've been happily using for years that is causing problems in 2019. The problem is easily fixed with two mouse clicks after the script runs, but I can't figure out a way to script it. The script below makes two base cabinet objects and a countertop that is a floor object. Starting in 2019, the floor object doesn't take the class texture. If you change anything in the attributes palette the texture pops in immediately. i.e. changing the line weight or turning on drop shadow or changing the opacity fixes the texture. So one fix with the GUI is to change the line weight and then change it back to by class. I've tried scripting that both in the original creation script and in a separate script. I can script a line weight change and watch the value change, but the texture doesn't pop in. Changing it in the attributes palette fixes it. QUESTION: What is the difference between SetLW(h,#); and using the GUI to do the same thing? QUESTION: What other tricks can I script to force the floor object to redraw and take on the class texture? Thanks! I'm eager to learn of some new-to-me level scripting mystery about the difference between user input and script command! Procedure FastBaseCabinets; {Badly Scripted by Michael Klaers.} {July, 2016 Airport Bar.} {This script will get two user clicks and draw 2 Base Cabinets between them.} {Update December 2016. On an airplane. v2017 cabinets insert in the opposite direction from v2016. This version corrects for that.} {Updated December 9,2018. Fixes countertop height on layers with elevation not on the internal origin. Layer elevation is in mm. Update divides layer elevation by 25.4 to get inches. } {Class Assignments: Base Cabinet in class Cabinet-Base Body of Cabinet in Cabinet-Body Door of Cabinet in Cabinet-Door } VAR CurrentClass, CabinetClass : STRING; CabinetDoorClass, CabinetBodyClass, CabinetKickClass : STRING; PullName : STRING; CabinetInQuestion : HANDLE; CabinetLengthTEXT, LineLengthText,StandardLengthText : STRING; LastCabinetLengthText : STRING; LineLength, StandardLength,LastCabinetLength : REAL; p1X, p1Y, p2X, p2Y,p1Z, p2Z, CalculatedAngle : REAL; V, OffsetVector, UntVector, RAUntVector : VECTOR; NumberOfCabinets,Index,NumberOfStandardLength : INTEGER; FirstClick, SecondClick, NextPoint, CntrTpPoint : POINT; CurrentUseAtCreation, WouldYouLikeACountertopWithThat : BOOLEAN; CounterTopDepth, CounterTopThickness, CounterTopHeight : REAL; CounterTopClass : STRING; CounterTopH : HANDLE; LayerBaseElev, LayerThickness : REAL; PROCEDURE SetCabinetParameters(CabinetInQuestion:HANDLE); BEGIN SetRField(CabinetInQuestion,'Base Cabinet','Length', LineLengthText); SetRField(CabinetInQuestion,'Base Cabinet','Style','Standard'); SetRField(CabinetInQuestion,'Base Cabinet','End Finish','None'); SetRField(CabinetInQuestion,'Base Cabinet','Blind','None'); SetRField(CabinetInQuestion,'Base Cabinet','Uneven','False'); SetRField(CabinetInQuestion,'Base Cabinet','Left Length','4''0"'); SetRField(CabinetInQuestion,'Base Cabinet','Height','2''11"'); SetRField(CabinetInQuestion,'Base Cabinet','Depth','2''0"'); SetRField(CabinetInQuestion,'Base Cabinet','Door mounting','Surface'); SetRField(CabinetInQuestion,'Base Cabinet','No_Drawer','False'); SetRField(CabinetInQuestion,'Base Cabinet','Drawer Style','Slab'); SetRField(CabinetInQuestion,'Base Cabinet','Number of Doors','2'); SetRField(CabinetInQuestion,'Base Cabinet','Door Style','Slab'); SetRField(CabinetInQuestion,'Base Cabinet','Panel Style','Raised'); SetRField(CabinetInQuestion,'Base Cabinet','ArchHeightFact','1'); SetRField(CabinetInQuestion,'Base Cabinet','Mullion Style','None'); SetRField(CabinetInQuestion,'Base Cabinet','Door Swing','Right'); SetRField(CabinetInQuestion,'Base Cabinet','RailStileWidth','1"'); SetRField(CabinetInQuestion,'Base Cabinet','Bevel Edge','False'); SetRField(CabinetInQuestion,'Base Cabinet','Bevel Inside','True'); SetRField(CabinetInQuestion,'Base Cabinet','Top Reveal','0.25"'); SetRField(CabinetInQuestion,'Base Cabinet','Bottom Reveal','0.25"'); SetRField(CabinetInQuestion,'Base Cabinet','Side Reveal','0.25"'); SetRField(CabinetInQuestion,'Base Cabinet','Center Reveal','0.25"'); SetRField(CabinetInQuestion,'Base Cabinet','Mid Reveal','0.25"'); SetRField(CabinetInQuestion,'Base Cabinet','NumShelves','1'); SetRField(CabinetInQuestion,'Base Cabinet','No Kick','True'); SetRField(CabinetInQuestion,'Base Cabinet','Kick Height','4"'); SetRField(CabinetInQuestion,'Base Cabinet','Kick Inset','4"'); SetRField(CabinetInQuestion,'Base Cabinet','Draw Counter','False'); SetRField(CabinetInQuestion,'Base Cabinet','Back Splash','Standard'); SetRField(CabinetInQuestion,'Base Cabinet','Splash Height','4"'); SetRField(CabinetInQuestion,'Base Cabinet','Splash Thickness','1"'); SetRField(CabinetInQuestion,'Base Cabinet','Counter Thickness','1.5"'); SetRField(CabinetInQuestion,'Base Cabinet','Overhang','1"'); SetRField(CabinetInQuestion,'Base Cabinet','Reveal','0.5"'); SetRField(CabinetInQuestion,'Base Cabinet','Show Detail','True'); SetRField(CabinetInQuestion,'Base Cabinet','Hidden',CabinetBodyClass); SetRField(CabinetInQuestion,'Base Cabinet','Doors',CabinetDoorClass); SetRField(CabinetInQuestion,'Base Cabinet','Kick',CabinetKickClass); SetRField(CabinetInQuestion,'Base Cabinet','Glazing',''); SetRField(CabinetInQuestion,'Base Cabinet','Counter',''); SetRField(CabinetInQuestion,'Base Cabinet','Handle Height','2''2"'); SetRField(CabinetInQuestion,'Base Cabinet','One Door','False'); SetRField(CabinetInQuestion,'Base Cabinet','Int Frame W','0"'); SetRField(CabinetInQuestion,'Base Cabinet','Per Frame W','0.25"'); SetRField(CabinetInQuestion,'Base Cabinet','__Version','2102'); SetRField(CabinetInQuestion,'Base Cabinet','__DoorHandle',PullName); SetRField(CabinetInQuestion,'Base Cabinet','__DrawerHandle',PullName); SetClass(CabinetInQuestion,CabinetClass); {Set Attributes to By Class} SetFillColorByClass(CabinetInQuestion); SetFPatByClass(CabinetInQuestion); SetLSByClass(CabinetInQuestion); SetLWByClass(CabinetInQuestion); SetMarkerByClass(CabinetInQuestion); SetOpacityByClass(CabinetInQuestion); SetPenColorByClass(CabinetInQuestion); SetTextStyleByClass(CabinetInQuestion); SetTextureRef(CabinetInQuestion,-1,3); ResetObject(CabinetInQuestion); END; Begin NumberOfCabinets := 2; {Main Program} CabinetClass := 'Cabinet-Base'; {Set Number of cabs, standard length, class names, etc.} CabinetDoorClass := 'Cabinet-Doors'; CabinetBodyClass := 'Cabinet-Body'; CabinetKickClass := 'Cabinet-Body'; PullName := 'Pull Bar01 4"-Chrome'; StandardLength := 18; StandardLengthText := Num2Str(9,StandardLength); CounterTopDepth := 25; CounterTopClass := 'Countertop'; CounterTopThickness := 1.5; CounterTopHeight := 36; WouldYouLikeACountertopWithThat := TRUE; CurrentClass := ActiveClass; DSelectAll; CurrentUseAtCreation := GetClUseGraphic(CurrentClass); NameClass(CabinetClass); SetClUseGraphic(CabinetClass,TRUE); GetLine3D( p1X, p1Y, p1Z, p2X, p2Y, p2Z, TRUE); {Get Points for beginning and end of Cabinets} FirstClick.x := p1X; {Create Point Object from first click} FirstClick.y := p1Y; SecondClick.x := p2X; {Create Point Object from second click} SecondClick.y := p2Y; V.x := p2X - p1X; {Create Vector object from points} V.y := p2Y - p1Y; V.z := 0; CalculatedAngle := Vec2Ang(V); {Angle between points} OffsetVector := V/NumberOfCabinets; {Length of equally spaced cabinets} UntVector := UnitVec(V); {Vector the same direction 1 unit (inch) long} RAUntVector := CounterTopDepth*Perp(UntVector); {Unit Vector 90° to the original unit vector * CntTop depth} LineLength := Norm(V)/NumberOfCabinets; {Distance between clicks} LineLengthText := Num2Str(9,LineLength); NumberOfStandardLength := Norm(V) DIV StandardLength; {# of standard length cabinets and lenght of remaining cab} LastCabinetLength := Norm(V) MOD StandardLength; LastCabinetLengthText := Num2Str(9,LastCabinetLength); IF LineLength >= 0 {Clicked length is more than 0} THEN BEGIN For Index := 1 to NumberOfCabinets DO {Create Standard length cabinets} BEGIN NextPoint.x := FirstClick.x + ((Index-1) * OffsetVector.x); {Draw cabinet at NextPoint,which is sandardlength * unit vector from first click} NextPoint.y := FirstClick.y + ((Index-1) * OffsetVector.y); CabinetInQuestion := CreateCustomObjectN('Base Cabinet',NextPoint.x,NextPoint.y,CalculatedAngle,FALSE); SetCabinetParameters(LNewObj); END; {End FOR 1 to # of Standard Length Cabinets} END; {End IF} {Draw Countertop} IF WouldYouLikeACountertopWithThat <> FALSE THEN BEGIN NameClass(CounterTopClass); SetClUseTexture(CounterTopClass,TRUE); GetLayerElevation(ActLayer,LayerBaseElev, LayerThickness); BeginFloor(CounterTopThickness); RectangleN(FirstClick.x, FirstClick.y, V.x, V.y, LineLength * NumberOfCabinets, -CounterTopDepth); EndGroup; CounterTopH := LNewObj; Move3D(0, 0, LayerBaseElev/25.4 + CounterTopHeight - CounterTopThickness); SetFillColorByClass(CounterTopH); SetFPatByClass(CounterTopH); SetLSByClass(CounterTopH); SetLWByClass(CounterTopH); SetMarkerByClass(CounterTopH); SetOpacityByClass(CounterTopH); SetPenColorByClass(CounterTopH); SetTextStyleByClass(CounterTopH); SetTextureRef(CounterTopH,-1,3); {For reasons unknown and perhaps undocumented:} {2nd argument: -1 references the class texture} {3rd argument: -3, -2, -1, 0 = top by class} { 1, 2 = nothing} { 3 = top, bottom, sides by class} END; NameClass(CurrentClass); {Reset Class and By Class to original} SetClUseGraphic(CurrentClass,CurrentUseAtCreation); End; Run(FastBaseCabinets); Floor Object Script Texture Fail.vwx Quote Link to comment
Julian Carr Posted September 3, 2019 Share Posted September 3, 2019 Wild guess. Try adding this: ResetObject(CounterTopH); at the end of the create floor section. Quote Link to comment
michaelk Posted September 3, 2019 Author Share Posted September 3, 2019 Hi Julian! I should have said in my original post. That was the first thing I tried! Quote Link to comment
Pat Stanford Posted September 3, 2019 Share Posted September 3, 2019 It is not your script. Even a really stripped down version has the same problem. I would suggest that you set the pen thickness to zero then you will only need single click to switch it to ByClass. Procedure Test; Var CounterTopH: Handle; BEGIN NameClass('Countertop'); SetClUseTexture('Countertop',TRUE); BeginFloor(4"); RectangleN(0,0,1,0,60,24); EndGroup; CounterTopH := LNewObj; SetFPatByClass(CounterTopH); ResetObject(CounterTopH); End; Run(Test); And by the way, patience is not always a virtue. 😞 Quote Link to comment
michaelk Posted September 4, 2019 Author Share Posted September 4, 2019 LOL Thanks for looking at it, Pat. So it works in 2016 - 2018. Something must have changed in the floor object for 2019. Half the things I try with the floor object make it go to no fill in OpenGL (change any render setting in the OIP, change the layer, rotate it, move it…) But even when it shows no fill changing ANY setting in the attributes palette fixes it. But I haven't (yet!) found any scripted solution that will make it wake up and realize it has a class texture. Quote Link to comment
LarryO Posted September 4, 2019 Share Posted September 4, 2019 Just a stab in the dark here, but have you tried ReDraw or ReDrawAll? Or applying attributes to the rectangle before ending the floor statement (and then to the parent floor as you do already)? 1 Quote Link to comment
michaelk Posted September 4, 2019 Author Share Posted September 4, 2019 Good idea. Just tried it. Nope. Quote Link to comment
Pat Stanford Posted September 4, 2019 Share Posted September 4, 2019 Submit a bug. Include the short script. Does this happen to manually drawn floors also? Quote Link to comment
michaelk Posted September 4, 2019 Author Share Posted September 4, 2019 Yes. Sometimes. Quote Link to comment
Pat Stanford Posted September 4, 2019 Share Posted September 4, 2019 Then see if you can submit a sample file with a manually drawn floor that shows the problem. Probably easier for them to troubleshoot. 1 Quote Link to comment
michaelk Posted September 13, 2019 Author Share Posted September 13, 2019 OK. This script works in 2018 and 2020. Not 2019. Arggggg. 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.