What's new

How to collinear constrain a line?

albie0803

Alibre Super User
Profile.AddConstraint([Line.Start, Profile.Origin],Sketch.Constraints.Coincident)

throws the following error.

EnvironmentError: System.Runtime.InteropServices.COMException (0x8000FFFF): Unable to cast object of type 'com.alibre.dcm.DCMReferencePointUV' to type 'com.alibre.engineering.IBlockPrimitive'.
at com.alibre.automation.ExceptionMap.handleException(Exception inputException)
at com.alibre.automation.AlibreSketchConstraints.AddConstraint(IObjectCollector targets, ADSketchConstraintType type)
at AlibreScript.API.Sketch.AddConstraint(List Figures, Constraints Constraint)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at Microsoft.Scripting.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at AlibreScript.UI.IronTextBoxControl.#ijb(Object #9A)
 

idslk

Alibre Super User
Hello albie0803,

the error says it can't cast one type into another.
As far as i'm not on the beta, can you try
Code:
print 'Type of Line.Start:',type(Line.Start)
print 'Type of Profile.Origin:',type(Profile.Origin)
Regards
Stefan
 

albie0803

Alibre Super User
Results from above are:

Type of Line.Start: <type 'SketchPoint'>
Type of Profile.Origin: <type 'SketchPoint'>

and I see why Coincident doesn't work.
 

albie0803

Alibre Super User
Neither of those objects are circles or arcs. They are sketchpoints. Try Coincident instead.

Concentric is just a shortcut to make arcs and circles have the same center point. So internally it gets the centers and does a Coincident constraint with some makeup of a different icon.

Coincident needs a line and a point to work.

In sketch mode you can use Concentric to move a node or a line endpoint to the Origin, not just circular sketch objects.
 

ajayre

Alibre Super User
Profile.AddConstraint([Line.Start, Profile.Origin],Sketch.Constraints.Coincident)

throws the following error.

EnvironmentError: System.Runtime.InteropServices.COMException (0x8000FFFF): Unable to cast object of type 'com.alibre.dcm.DCMReferencePointUV' to type 'com.alibre.engineering.IBlockPrimitive'.

That is an error inside AD - please submit to support so they can look at it. Andy
 

albie0803

Alibre Super User
So I had a thought and have devised a workaround in order to anchor my sketch to the origin.
I created a vertical reference line from zero called Y-Line, fixed it and then did a collinear constraint with my first vertical line.
I then did the same with a horizontal one.
My sketch is now anchored as I want it.
 
Top