Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BillBoard property(ScreenBillBoardStyle) of CustomGraphicsText

4 REPLIES 4
Reply
Message 1 of 5
kandennti
350 Views, 4 Replies

BillBoard property(ScreenBillBoardStyle) of CustomGraphicsText

Hi.

 

I want to use the BillBoard property(ScreenBillBoardStyle) of CustomGraphicsText to create text that always matches the orientation of the screen, but it doesn't work the way I want it to.

 

If anyone has successfully done this, please advise me. Please give me some advice.

 

It is hard to understand, but I created the following test code.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui: adsk.core.UserInterface = None
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        removeCG()

        billBoarding = True

        testData = [
            [
                'AB',
                adsk.core.Point3D.create(0,0,0),
                billBoarding
            ],
            [
                'CDE',
                adsk.core.Point3D.create(10,20,30),
                billBoarding
            ],
            [
                'FGHI',
                adsk.core.Point3D.create(-30,-20,-10),
                billBoarding
            ]
        ]

        for t, p, b in testData:
            initCGtext(root, t, p, b)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def initCGtext(
    comp: adsk.fusion.Component,
    txt: str,
    pnt: adsk.core.Point3D,
    isBillBoarding: bool
    ) -> adsk.fusion.CustomGraphicsText:

    vec: adsk.core.Vector3D = pnt.asVector()
    mat: adsk.core.Matrix3D = adsk.core.Matrix3D.create()
    mat.translation = vec

    cgGroup: adsk.fusion.CustomGraphicsGroup = comp.customGraphicsGroups.add()
    cgTxt: adsk.fusion.CustomGraphicsText = cgGroup.addText(
        txt,
        'Arial',
        3,
        mat)
    cgTxt.isBold = True
    # cgTxt.isSelectable = False

    if isBillBoarding:
        billBoard = adsk.fusion.CustomGraphicsBillBoard.create(pnt)
        billBoard.billBoardStyle = adsk.fusion.CustomGraphicsBillBoardStyles.ScreenBillBoardStyle
        cgTxt.billBoarding = billBoard

    # ***confirmation***
    skt: adsk.fusion.Sketch = comp.sketches.add(comp.xYConstructionPlane)
    skt.name = txt
    bBox: adsk.core.BoundingBox3D = cgTxt.boundingBox
    oriBBox: adsk.core.OrientedBoundingBox3D = toOriented(bBox)
    drawPoint(skt, pnt)
    drawPointWHRectangle(skt, pnt, oriBBox.length, oriBBox.width)
    drawBBox(comp, bBox, txt)

    return cgTxt

def drawBBox(
    comp: adsk.fusion.Component,
    bBox: adsk.core.BoundingBox3D,
    name: str):

    oriented = toOriented(bBox)

    tmpMgr: adsk.fusion.TemporaryBRepManager = adsk.fusion.TemporaryBRepManager.get()
    box: adsk.fusion.BRepBody = tmpMgr.createBox(oriented)

    baseFeat : adsk.fusion.BaseFeature = comp.features.baseFeatures.add()
    baseFeat.startEdit()
    body: adsk.fusion.BRepBody = comp.bRepBodies.add(box, baseFeat)
    body.opacity = 0.5
    body.name = name
    baseFeat.finishEdit()

def toOriented(
    bBox: adsk.core.BoundingBox3D) -> adsk.core.OrientedBoundingBox3D:

    pMax: adsk.core.Point3D = bBox.maxPoint
    pMin: adsk.core.Point3D = bBox.minPoint

    center = adsk.core.Point3D.create(
        (pMax.x + pMin.x) * 0.5,
        (pMax.y + pMin.y) * 0.5,
        (pMax.z + pMin.z) * 0.5
    )

    return adsk.core.OrientedBoundingBox3D.create(
        center,
        adsk.core.Vector3D.create(1,0,0),
        adsk.core.Vector3D.create(0,1,0),
        abs(pMax.x - pMin.x),
        abs(pMax.y - pMin.y),
        abs(pMax.z - pMin.z)
    )

def drawPoint(
    skt: adsk.fusion.Sketch,
    pnt: adsk.core.Point3D):

    skt.sketchPoints.add(pnt)

def drawPointWHRectangle(
    skt: adsk.fusion.Sketch,
    pnt: adsk.core.Point3D,
    w: float,
    h: float):

    p: adsk.core.Point3D = pnt.copy()
    p.x += w
    p.y += h

    skt.sketchCurves.sketchLines.addTwoPointRectangle(pnt, p)

def removeCG():
    app: adsk.core.Application = adsk.core.Application.get()
    des :adsk.fusion.Design = app.activeProduct
    cgs = [cmp.customGraphicsGroups for cmp in des.allComponents]
    cgs = [cg for cg in cgs if cg.count > 0]
    
    if len(cgs) < 1: return

    for cg in cgs:
        gps = [c for c in cg]
        gps.reverse()
        for gp in gps:
            gp.deleteMe()

The execution result is as shown here.

1.png

2.png

・A(sketch point)

 The location of the reference when creating CustomGraphicsText.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F25572F5-ABD7-4322-80FE-5D4AF8E8917B 

 

 AnchorPoint for BillBoarding

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-5EA7799D-2419-48A2-81E9-6CB7F9D1CC9F

 

・B(Sketch Profile)

 The square created by the CustomGraphicsText's AnchorPoint+width+height.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-BF25E5D8-ECD4-495A-BC01-804CAB93F5AF 

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-17427A1A-F387-42E0-B96E-3C2022F2320A 

 

・C(Surface)
Body created by CustomGraphicsText.boundingBox.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-C09A0588-4CE3-42E9-9588-93FA718D01F0 

 

 

The one created at the origin (AB) will work as desired.
However, the ones that are far away from the origin (CDE, FGHI) are far away from the AnchorPoint and do not perform the desired motion.

3.png

I did a lot of research, but could not find out the cause.
Has anyone used CustomGraphicsText's BillBoard(ScreenBillBoardStyle)?

 

 

A few questions about the documentation.

・I think the description of CustomGraphicsGroup.addText is correct "bottom-left".(It's listed in multiple parts.)

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F25572F5-ABD7-4322-80FE-5D4AF8E8917B 

4.png

 

・It seems that the boundingBox property is not positioned correctly.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-C09A0588-4CE3-42E9-9588-93FA718D01F0 

Since the Z value of the boundingBox is not "0", I interpret that it is not a result in pixel space.

 

・I was not sure where to find the "isViewDependent property" mentioned in the AnchorPoint description.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-DA642B2F-0206-40B3-8328-0F54C40BDEA5 

 

・The "CustomGraphicsAnchorPoint object" listed in the CustomGraphicsBillBoard.anchorPoint Property description was not found.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-5EA7799D-2419-48A2-81E9-6CB7F9D1CC9F 

4 REPLIES 4
Message 2 of 5
BrianEkins
in reply to: kandennti

I can reproduce this and it seems like a bug to me.  I'll make sure a bug gets filed.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 5
kandennti
in reply to: BrianEkins
Message 4 of 5
MichaelT_123
in reply to: kandennti

Hi Kendennti-San,
I had a quick look. Yes, it seems that there is something wrong with BillBoard functions.
There is also another discrepancy.
The sizes of textObjects created in a sketch environment and those in CustomGraphicText differ significantly.

 

It would be nice if they were addressed together.

CustomText_A.png

Regards
MichaelT

PS.

There is probably some issue in the procedure generating bodies...

MichaelT
Message 5 of 5
kandennti
in reply to: BrianEkins

I have confirmed that this has been fixed in Ver 2.0.14104.
Thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report