Paolo Posted April 15, 2022 Share Posted April 15, 2022 Objects 3D that are constructed within Vectorworks primitive tools (extrusions, extrusions along path, etc.) have full texture controls in the object render pane. This is not true for custom plugin objects that creates parametric 3D objects, as far as I know… Just the texture choice is available… Is there a way to show all the options? 1 Quote Link to comment
FabioParenti Posted December 7, 2022 Share Posted December 7, 2022 Didn't anyone evere answered to this? I've the same problem ,I'm looking for a method to avoid it. No need of complex Texture editing, just Mapping, scale etc... o 1 Quote Link to comment
Paolo Posted December 9, 2022 Author Share Posted December 9, 2022 Hello Fabio, in the simplest case, with just one object 3D created in the plugin, the "core" is in the following lines: hTrim = vs.LNewObj() #hTrim is my 3D object I want to control the texture from collections import namedtuple Trim = namedtuple('Trims', ['trim']) obj = Trim(hTrim); if not vs.CustomTexPartExists(parmHand, 1000): #parmHand is the plugin's handle vs.SetTextureSet(parmHand,1) vs.RemoveCustomTexParts(parmHand) vs.AddCustomTexPart(parmHand, 1000, 'trim') vs.SetDefaultTexMapN(parmHand, 1000, 0) vs.ApplyCustomTexPart(parmHand,obj.trim,1000); setTexture(obj.trim, parmHand, 1000, materialChange, classChange) The setTexture function (following) is where we set / get the OIP texture panel: #************************ setTexture ************************# def setTexture(h, hPio, idx, materialChange, classChange): #classes if not vs.PuseMaterials and materialChange: vs.SetClass(h, vs.GetClass(hPio)) vs.SetTextureRefN(hPio, vs.GetClTextureG(vs.GetClass(h)), idx, 0) vs.SetTextureRefN(hPio, -1, idx, 0) vs.ResetObject(hPio) #*** material ***# if vs.PuseMaterials and materialChange: vs.SetClUseTexture(vs.GetClass(hPio), False) if vs.Pmaterials == '': MyList, NumItems = vs.BuildResourceList(19, 0, '') if NumItems == 0: MyList, NumItems = vs.BuildResourceList2(19, 345, '', True) #get it from the library #here I have at least the default material if NumItems > 0: result = vs.SetObjMaterialHandle(h, vs.GetObject(vs.GetNameFromResourceList(MyList, 1))) result = vs.SetObjMaterialHandle(hPio, vs.GetObject(vs.GetNameFromResourceList(MyList, 1))) vs.SetRField(hPio, vs.GetName(vs.GetParametricRecord(hPio)), 'materiale', vs.GetNameFromResourceList(MyList, 1)) #materiale is a parameter of type Material vs.SetRField(hPio, vs.GetName(vs.GetParametricRecord(hPio)), 'materials', vs.GetNameFromResourceList(MyList, 1)) else: result = vs.SetObjMaterialHandle(h, vs.GetObject(vs.Pmaterials)) result = vs.SetObjMaterialHandle(hPio, vs.GetObject(vs.Pmaterials)) vs.SetRField(hPio, vs.GetName(vs.GetParametricRecord(hPio)), 'materiale', vs.Pmaterials) hMaterial = vs.GetObjMaterialHandle(h) textureRef = vs.GetMaterialTexture(hMaterial) vs.SetTextureRefN(hPio, textureRef, idx, 0) vs.SetTextureRefN(h, textureRef, 3, 0) if vs.PuseMaterials: result = vs.SetObjMaterialHandle(h, vs.GetObject(vs.Pmaterials)) result = vs.SetObjMaterialHandle(hPio, vs.GetObject(vs.Pmaterials)) if vs.Pmaterials == '': vs.ResetObject(hPio) #changes in OIP rendering if vs.GetTextureRefN(hPio, idx, 0, False) == -1 : vs.SetTextureRefN(h, vs.GetClTextureG(vs.GetClass(h)), 3, 0) else: vs.SetTextureRefN(h, vs.GetTextureRefN(hPio, idx, 0, False), 3, 0) if vs.GetTextureRefN(hPio, idx, 0, False) == 0 : vs.SetTextureRefN(hPio, 0, 3, 0) else: vs.SetTexMapInt(h, 3, 1, vs.GetTexMapIntN(hPio, idx, 0, 1)); vs.SetTexMapBoolN(h, 3, 0, 1, vs.GetTexMapBoolN(hPio, idx, 0, 1)) vs.SetTexMapBoolN(h, 3, 0, 2, vs.GetTexMapBoolN(hPio, idx, 0, 2)) vs.SetTexMapBoolN(h, 3, 0, 3, vs.GetTexMapBoolN(hPio, idx, 0, 3)) vs.SetTexMapBoolN(h, 3, 0, 4, vs.GetTexMapBoolN(hPio, idx, 0, 4)) vs.SetTexMapBoolN(h, 3, 0, 5, vs.GetTexMapBoolN(hPio, idx, 0, 5)) vs.SetTexMapBoolN(h, 3, 0, 6, vs.GetTexMapBoolN(hPio, idx, 0, 6)) vs.SetTexMapBoolN(h, 3, 0, 7, vs.GetTexMapBoolN(hPio, idx, 0, 7)) vs.SetTexMapRealN(h, 3, 0, 1,vs.GetTexMapRealN(hPio, idx, 0, 1)) vs.SetTexMapRealN(h, 3, 0, 2,vs.GetTexMapRealN(hPio, idx, 0, 2)) vs.SetTexMapRealN(h, 3, 0, 3,vs.GetTexMapRealN(hPio, idx, 0, 3)) vs.SetTexMapRealN(h, 3, 0, 4,vs.GetTexMapRealN(hPio, idx, 0, 4)) vs.SetTexMapRealN(h, 3, 0, 5,vs.GetTexMapRealN(hPio, idx, 0, 5)) The variables materialChange and classChange are triggered by the user acting on some parameters in the OIP: # *** material change *** if vs.IsNewCustomObject(parmName): vs.SetObjectVariableBoolean(parmHand, 800, False) result, widgID, prmIndex, oldValue = vs.vsoStateGetParamChng(parmHand) if result or vs.GetObjectVariableBoolean(parmHand, 800): result, outWidgetID = vs.vsoPrmName2WidgetID('', 'materials') #materials menu managed in event kObjOnWidgetPrep and in setTexture if (widgID == outWidgetID): materialChange = True result, outWidgetID = vs.vsoPrmName2WidgetID('', 'useMaterials') #checkbox if (widgID == outWidgetID): materialChange = True if vs.GetObjectVariableBoolean(parmHand, 800): materialChange = True classChange = True vs.SetObjectVariableBoolean(parmHand, 800, False) Of course, in the case you have more materials in one plugin (such I have in some of my Mouldings Plugins), things get more complicated. 1 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.