What's new

Script / Python Concepts

albie0803

Alibre Super User
This is something that I hope will help others who are learning to grapple with Python and scripting.

I wanted to add a plane to a part and so looked up the reference for add plane.
Parameters
Name Name of plane
SourcePlane Plane/face to use as basis
Offset Offset from basis plane in currently chosen units

So I tried this but got an error

P = CurrentPart()
P.AddPlane('KeyFace', Face<2>, 0)

I enquired as to why and was told to replace "Face<2>" with P.GetFace("Face<2>")

giving

P.AddPlane('KeyFace', P.GetFace("Face<2>"), 0)

which of course worked.

This led me to realise that a lot of commands don't work with text values, they work with objects.

The source plane/face parameter required not just the name of the plane/face, but a named plane/face object.

Imagine:
♥ = Face Object
♦ = Plane Object
♣ = Edge Object
♠ = Axis Object

FC = P.GetFace("Face<2>") actually creates a Face object from Face<2> called FC >> ♥(FC)

So the command is actually P.AddPlane('KeyFace', ♥(FC), 0) >> Plane Name, Face Object, Offset Distance

This concept is the same for Axis, Edge, Plane and any other item that uses a Get command
 
Last edited:

DavidJ

Administrator
Staff member
Thanks - that becomes fairly obvious when explained, but nothing I've seen in the reference document really emphasises that. In some documentation for programming, the 'type' of each parameter is explicitly stated (or shown using specific fonts).

This is probably another case of 'it's so obvious to an experienced programmer' that it doesn't get mentioned in the manual - doesn't help those just getting started.
 

oldfox

Alibre Super User
Imagine:
♥ = Face Object
♦ = Plane Object
♣ = Edge Object
♠ = Axis Object

FC = P.GetFace("Face<2>") actually creates a Face object from Face<2> called FC >> ♥(FC)

So the command is actually P.AddPlane('KeyFace', ♥(FC), 0) >> Plane Name, Face Object, Offset Distance

This concept is the same for Axis, Edge, Plane and any other item that uses a Get command

+100
Thank you, thank you.
 

oldfox

Alibre Super User
This is probably another case of 'it's so obvious to an experienced programmer'

Right on, David. I mentioned before that exact thing. Producing a good manual requires both the programmer/engineer/designer and the tech writer to work hand in hand to get a good end product.
 
Top