Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid too many dialogs. Fix crash when one of the objects is not a co… #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion NesterCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,17 @@ def createJoint(face1, face2):
if face1.assemblyContext == face2.assemblyContext:
ui.messageBox("Faces are from the same Component. Each part must be a component")
adsk.terminate()
return False

elif not face2.assemblyContext:
ui.messageBox("Face is from the root component. Each part must be a component")
adsk.terminate()
return False

elif not face1.assemblyContext:
ui.messageBox("Face is from the root component. Each part must be a component")
adsk.terminate()
return False

else:
# Create the joint geometry
Expand All @@ -113,6 +116,8 @@ def createJoint(face1, face2):
# Create the joint
joints.add(jointInput)

return True

# Returns a normalized vector in positive XYZ space from a given edge
def getPositiveUnitVectorFromEdge(edge):
# Set up a vector based on input edge
Expand Down Expand Up @@ -150,6 +155,7 @@ def transformAlongVector(select, directionVector, magnatude):
vector.scaleBy(magnatude)

# Create a transform to do move
if select is None or select.assemblyContext is None: return
transform = adsk.core.Matrix3D.cast(select.assemblyContext.transform)
newTransform = adsk.core.Matrix3D.create()
newTransform.translation = vector
Expand Down Expand Up @@ -218,7 +224,7 @@ def onExecute(self, command, inputs):

# Apply Joints
for face in newFaces:
createJoint(face, plane)
if not createJoint(face, plane): return

# Arrange Components
arrangeComponents(newFaces, plane, edge, spacing)
Expand Down