- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all, basically what Im trying to do is to create a rectangle by using "AddAsTwoPointCenteredRectangle" command and make that rectangles center Coincident to center point of the sketch.
Here is my code
Sub Main() ' Define the inputs for the dimensions of the first rectangle Dim length1 As Double Dim width1 As Double ' Prompt the user to input the dimensions of the first rectangle length1 = CDbl(InputBox("Enter the length of the first rectangle", "Rectangle Dimensions", "10")) width1 = CDbl(InputBox("Enter the width of the first rectangle", "Rectangle Dimensions", "5")) Dim oPartCompDef As PartComponentDefinition oPartCompDef = ThisApplication.ActiveDocument.ComponentDefinition Dim oSketch As PlanarSketch oSketch = oPartCompDef.Sketches.Add(oPartCompDef.WorkPlanes.Item(3)) Dim halfLength1 As Double Dim halfWidth1 As Double halfLength1 = length1 / 2 halfWidth1 = width1 / 2 Dim oRectangleLines As Object With ThisApplication.TransientGeometry oRectangleLines = oSketch.SketchLines.AddAsTwoPointCenteredRectangle( _ .CreatePoint2d(0, 0), _ .CreatePoint2d(halfLength1, halfWidth1)) End With Dim oLine1 As SketchLine Dim oLine2 As SketchLine Dim oLine3 As SketchLine Dim oLine4 As SketchLine oLine1 = oRectangleLines(1) oLine2 = oRectangleLines(2) oLine3 = oRectangleLines(3) oLine4 = oRectangleLines(4) Dim oOriginPoint As SketchPoint oOriginPoint = oSketch.OriginPoint Dim oMidPoint As Point2d oMidPoint = oLine1.Geometry.MidPoint Dim oMidSketchPoint As SketchPoint oMidSketchPoint = oSketch.SketchPoints.Add(oMidPoint)
'This is the place where Im getting the error messages Call oSketch.GeometricConstraints.AddCoincident(oMidSketchPoint, oOriginPoint) End Sub
Im gettin this error mesage;
System.ArgumentException: Parametre hatalı. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.GeometricConstraints.AddCoincident(SketchEntity EntityOne, SketchEntity EntityTwo)
at ThisRule.Main() in rule: Rectangle, in document Core(V-01).ipt:line 47
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Can someone give me an idea ?
Solved! Go to Solution.