Calling SheetMetal Commands from LISP code
In order to call the sheet
metal command from LISP you usually have to compose a proper
preselection: i.e. if a command expects an entity, a solid must be
preselected, if a command works with faces, faces must be
preselected.
Here you should exploit the fact that
SmLispGet returns selection sets for features, so just right after
a successful SmLispGet call you can call the required command, i.e.
you can query faces of the flange first, and then call SmBendCreate
to create bends on hard edges of the given flange
(SmLispGet "SelectEntities"
"Top" "Flange_1")
(command "SmBendCreate")
Next, in your script you have
to program a proper sequence of command options (if it has some
modes) and finally you should check the return code by reading the
errno variable. In our sample scripts we use three
values:
(setq gError 79)
(setq gWarning 1)
(setq gSuccess 0)
Return code equal to 0 means
the command is executed successfully. 79 means a fatal error
has occurred, in which case it is better to stop the treatment of
the model or the entire script and notify the user that the
operation was unsuccessful, and the continuation of the scenario is
not possible.
Warnings have to be treated up to context,
they mean that command has succeeded, but some problems, which the
system cannot resolve, have been detected.
Their treatment depends on the context: they
can either be neglected or remembered to inform the user about some
issues.
But the main point is that if you get a
warning, you can continue the scenario.
Let's continue the example to clarify the
idea:
(SmLispGet "SelectEntities"
"Top" "Flange_1")
(command "SmBendCreate")
(if (= gError (getvar "errno"))
(progn
(print "Failed to create bends!
Exiting")
(exit)
)
)
© Bricsys NV. All rights reserved. |