Graphics

 View Only
Expand all | Collapse all

Help with scripting

  • 1.  Help with scripting

    Posted 09-23-2019 10:36

    Hi,

    I'd like to use a script to assign a face material to a quad depending on the code ( P01 to P27) obtained from a datalinqed xml file (http://adress.xml  for example)

    I did that with VL but I'd like to start using scripts and I don't know anything about  scripting!

    If somebody would be kind enough to help me I would really appreciate it.

    The explanations for the lines of code would be a plus for me to understand what does what!

    Here is a sample of how I did it in VL , if  it can help you to understand what I need

    Best regards

    Michel



  • 2.  RE: Help with scripting

    Posted 09-23-2019 13:20

    does that input selector go all the way to 27!??? Goodness!

    To me it looks like you have a text object and if it says P# apply the P# material to your quad. Do I have that right? If so you may be able to have a very simple code that takes the contents of a text object and passes that into a SetMaterial method directly to your quad.

    There could be some more questions here that need to be answered, but I think you can probably get something very straightforward with under 10 lines of code.


    #XPression


  • 3.  RE: Help with scripting

    Posted 09-23-2019 13:26

    You are totally right Martin, I know that this could probably be done easily by somebody who knows how to code, but this is not my case so I managed my own way for the moment.


    #XPression


  • 4.  RE: Help with scripting

    Posted 09-23-2019 17:17

    Michel,

    Can we get a copy of the project, and the XML file? i'll see if I can write a script and insert comments to break down how it works!


    #XPression


  • 5.  RE: Help with scripting

    Posted 09-23-2019 18:35

    Hi Brandon,

    Thanks for paying attention to my request.

    How can I Join a xpp file and a xml file in my post?

    can you send me your email?

    Best regards

     


    #XPression


  • 6.  RE: Help with scripting

    Posted 09-23-2019 18:40

    Hey Michel,

    My email is bderry@rossvideo.com


    #XPression


  • 7.  RE: Help with scripting

    Posted 09-23-2019 18:57

    Brandon may have something more specific, but here is a simple OnOnline script:

    ' Declares Objects within your scene as specific datatypes
    dim quad as xpBaseObject
    dim textChecker as xpTextObject
    dim quadMat as xpMaterial

    'References the Scene to find objects in your Object Manager
    'the two objects would be called TextChecker and Quad
    Self.GetObjectByName("TextChecker",textChecker)
    Self.GetObjectByName("Quad",quad)

    'Uses the GetMaterialByName method to pull in
    'a material from your material manager and assigned it as the quadMat variable
    'the textChecker.Text references the Text Property, or contents of your text box
    'in your case it could be a datalinq source
    '
    'A material called "P0" would be assigned
    'if the string "P0" was in the text field
    Self.Project.GetMaterialByName(textChecker.Text,quadMat)

    'With the proper objects assigned, we still need to take 1 more step
    'Here we are telling the quad object to use the SetMaterial method
    'the 0 represents the index of the face we are assigning
    'from above, quadMat = textChecker.Text
    quad.SetMaterial(0,quadMat)


    #XPression


  • 8.  RE: Help with scripting

    Posted 09-24-2019 12:02

    Thanks so much Martin, your script works perfectly.

    I definitively have to learn how to script but as I learned to use Xpression by myself and there are very few tutos on VL and Scripting it's hard for me .

    I have really appreciate your explanations 

    Would you have any reading to suggest me on those subjects

    Thanks a million

    Best regards


    #XPression


  • 9.  RE: Help with scripting

    Posted 09-24-2019 13:09

    Well there's hope for you yet, I struggled in my CS classes back in college well over a decade ago, so if I can pick it up you can too! As I like to say computers are dumb, you have to tell them EXACTLY what you want them to do. So it comes down to knowing, or at least knowing where to find, how to do things with scripts.

    I would suggest start by getting yourself an introductory book on Visual Basic (I've always liked the O'Reily publications). This will help you starting to find your way around the Xpression SDK in the help section.

    Additonally, Microsoft is gracious enough to provide its own SDK for visual basic: https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/dim-statement

    You can also find plenty of youtube videos on programming, I'd start with some conceptual basics on Object Oriented Programming.

    I'm by no means an expert, but my fear of scripting has subsided now that I've gotten into it, it looks more complicated than it  actually is.

     


    #XPression


  • 10.  RE: Help with scripting

    Posted 09-24-2019 15:56

    Thanks for your good words and your tips and just for you to understand me better, I must tell you that if you finished your college over a decade ago, I finished mine almost 4 decades ago . lol

    Anyway , all the help that I find on this forum is very appreciated and I'm sure that you will see my name again on other questions, I have millions of them ;)

    Best regards

    Michel


    #XPression


  • 11.  RE: Help with scripting

    Posted 12-05-2019 00:59

    Martin,
    Can i ask why“quad.setmaterial(0,mat)” the “0”must be 0? Can i sub to any number, if can not be ,what "0" means ?
    Thx


    #XPression


  • 12.  RE: Help with scripting

    Posted 12-06-2019 18:14

    It's the index of the face you want to change. Since Xpression supports 3D objects, I'm guessing the fine folks at ross had the presence of mind to give you the flexibility to change the material of an individual face of an object. The 0 in that case is the first (and maybe only) face of a quad. If you were say wanting to set a specific material on a cube object or something more elaborate, you could utilize that index to change that side.


    #XPression