sabato, novembre 16, 2013

3D View Depth Override - Update


In questo nuovo video mostro come funziona la versione del View Depth Override per le viste prospettiche.
Dato che non è possibile azionare le macro da una vista prospettica ho trovato un sistema per aggirare il problema.
Con la macro ViewListWrite viene creato un file di testo sul desktop chiamato [MyProjectName]-3DViews.txt, in cui vengono elencate per ciascuna riga le viste di prospettiva presenti nel progetto.
Con la macro ViewListRead viene eseguito il View Depth Override tante volte quante sono le viste elencate nel file di testo. Questo file di testo è editabile dall'utente ed è quindi possibile decidere su quali viste far eseguire la macro.
Il codice è migliorato dalla prima versione, grazie anche a degli spunti che ho trovato sul blog di Jeremy Tammik the Building Coder, in particolare per l'uso del Linq per determinare i punti di massimo e minimo.
Ho introdotto anche l'uso del Transform per rendere più leggibili le operazioni di calcolo dei punti del BoundingBoxXYZ orientato come la vista, la qual cosa si può felicemente applicare alla versione 2D del View Depth Override.

Si tratta sempre di un work in progress, i commenti sono bene accetti per cercare di migliorare :)

Codice sorgente:
Versione 2012
Versione 2014

5 commenti:

  1. Anonimo5:54 PM

    ciao paolo,

    non so esattamente cosa stai cercando di fare qui, ma sembra interessante.

    per favore fami sapere se te posso aiutare.

    ciao, jeremy.

    RispondiElimina
  2. Ciao Jeremy,
    once somebody told me you speak 6 or 7 languages fluently, now I know italian is one of them!
    You can help me for sure because I'm really new to API and C#.
    My goal is to find a way to get the user to select through a form a list of views (both 2D and 3D) and perform an override of the projection lines and the surface patterns based on the distance between the view and the objects.
    Based on the far clipping of the view (in a 2D view such as an elevation or section) a "bounding box filter" is defined and split into 3 equal segments (foreground, middle and background) defining two overrides for middle and for background.
    For 3D Views the approach I used is slightly different: a bounding a box for all the objects is transformed in perspective view coordinates and transformed again to convert it into a bounding box filter just like for 2D views, to make the override based on the distance between the objects and the eye of the camera but, actually, it doesn't work very well on some objects far from the camera and I couldn't investigate this particular issue properly.
    In the form I have in mind the user can set the colour, the line style, the pattern and the pattern style for middle and background segments separately (along with a visibility check box for the patterns).

    It works on model groups but I couldn't make it work on linked files: at the time I started I was using the 2012 API, but I guess an override for the entire file it's not a problem, I still haven't tried yet though.

    Any help I can get is really appreciated, especially from professionals like you, it means a lot to me, it's priceless, so thank you in advance.

    Cheers
    -Paolo

    RispondiElimina
  3. PS
    make the views automatically update when model changes occur... that would be another nice feature to add, maybe get it to work when the view is printed or an image is exported and of course when the file is opened.

    RispondiElimina
  4. Premetto che mi sembra un ottima macro con risvolti tecnici e di resa grafica notevoli aggiungo inoltre che sono un completo ignorante in C#

    ho un problemino con la v 2014...non è che potresti darmi un aiuto? Grazie in anticipo!

    alle righe (331, 33x)
    using (StreamWriter sw = new StreamWriter(path, false))
    stessa cosa per StreamReader
    mi da il seguente errore The type or namespace name 'StreamWriter' could not be found (are you missing a using directive or an assembly reference?) (CS0246)

    RispondiElimina
  5. Ciao Pietro,
    grazie per l'interessamento e della segnalazione.

    Sembrano errori dovuti alla mancanza di uno using statement all'inizio del codice.

    prova ad aggiungere insieme agli altri "using System.IO;" e dovrebbe funzionare.

    fammi sapere


    -paolo

    RispondiElimina