Redefining Construction Plane?

Redefining Construction Plane?

Anonymous
Not applicable
855 Views
5 Replies
Message 1 of 6

Redefining Construction Plane?

Anonymous
Not applicable

When it comes to modifying things, instead of creating them new, I find it very hard to find information or examples.

 

I'm trying to redefine an offset construction plane but I'm not getting it...

 

This was my "best bet" but I get an error: "ConstructionPlaneOffsetDefinition_redefine', argument 2 of type 'adsk::core::Ptr< adsk::core:ValueInput > const &' 

 

What am I missing or doing wrong?

 

xzPlane = rootComp.xZConstructionPlane

planeLeftEyeOP = rootComp.constructionPlanes.itemByName('Plane_LeftEyeOP')
planeDefinition = planeLeftEyeOP.definition

planeDefinition.redefine(newOffsetValue, xzPlane)

 

 

0 Likes
Accepted solutions (1)
856 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Accepted solution

Never mind.

 

I don't know why I need to do that here and not when I modify a sketch line for example, but defining the offset value like this worked:

 

newOffsetValue = adsk.core.ValueInput.createByReal('newOffset')

0 Likes
Message 3 of 6

kandennti
Mentor
Mentor

Hi ljkCRMAD.

 

Create an offset plane.
Then run a script and select a plane.

# Fusion360API_Python script
# +1Cm offset plane

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        # select
        msg = 'select offset plane'
        pln = selectOffsetPlane(ui, msg)
        if not pln: return

        # +1Cm
        prm :adsk.fusion.ModelParameter = pln.offset
        prm.value += 1

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

def selectOffsetPlane(
    ui :adsk.core.UserInterface,
    msg :str) -> adsk.fusion.ConstructionPlaneOffsetDefinition:

    filtterStr = 'ConstructionPlanes'
    offPlnDef = adsk.fusion.ConstructionPlaneOffsetDefinition
    while True:
        try:
            sel :adsk.core.Selection = ui.selectEntity(msg, filtterStr)
            offPln = offPlnDef.cast(sel.entity.definition)
            if not offPln:
                ui.messageBox('Type is OffsetPlane only!')
            else:
                return offPln
        except:
            return None

 

0 Likes
Message 4 of 6

MichaelT_123
Advisor
Advisor

Hi Fellows,

Why not right-click a constPlane in the Browser and perform the task.

Writing a good self-sufficient universal script would require some hard yakka.

Regards

MichaelT

MichaelT
0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi guys

 

Thanks for the replies, but as I wrote in my own reply, I already found the solution 🙂

 

The reason for doing this is because I'm creating an Add-In (actually just finished) that users in the production apartment of my company, with zero experience with CAD software, will be using many times a day.

Punching in some numbers in a dialog box and pressing OK is all they have to do...

I wouldn't be creating a script to change the definition of a construction plane under normal circumstances 😉

0 Likes
Message 6 of 6

MichaelT_123
Advisor
Advisor

Hi,

... the nice human approach.

Congrats

MichaelT

MichaelT
0 Likes