Hello Guys,
I am using inv2011. I have to create rec. blocks very often and in inv2011 . I have to constraint it in middle.
Can i write a Macto that gives me constraint rec block in sketch. This feature already available in Inv12.
Thanks
You dont have the ability to write macros in Inventor 2013 but you can automate some of the design process using ilogic.
Here are some links:
http://inventortrenches.blogspot.com/search/label/Autodesk%20Inventor%20iLogic
I hope this helps.
Cheers
Chris
Design Engineer
Sheffield UK
@Anonymous wrote:You dont have the ability to write macros in Inventor 2013 but you can automate some of the design process using ilogic.
I don't have enough skill with them to be able to help the OP with his request, but VBA macros are still available in Inv 2013.
Yea sorry I miss spoke, I ment you dont have the abilty to record macros in inventor so i thought ilogic might be the better may to go.
Yes, that's true, and unfortunately that feature has never existed (would be nice though).
kalpesh_43, I did some digging around. We used to use a macro that will (I think) do what you want, but took it out of our macro files when we set up 2013 since it had a function that replaces it. Fortunately I kept an exported copy of it for reference. This is based on one I found online somewhere a while ago, then modified slightly (mostly to add error catches that didn't exist in the original). I would give credit to the originator, but don't recall who that is.
Sub InitialRectangle() ' Make sure a part document is active. If ThisApplication.ActiveDocumentType <> kPartDocumentObject Then MsgBox "Must have a part active", vbOKOnly, "Error" Else Dim oPartDoc As PartDocument 'for the active part Dim oCompDef As PartComponentDefinition Dim oSketch As PlanarSketch Dim oLines(1 To 4) As SketchLine 'each of the 4 sides of the rectangle Dim oRectLines As SketchEntitiesEnumerator Dim count As Integer Dim XVal As Integer Dim YVal As Integer Dim bFoundOrigin As Boolean Dim oTransGeom As TransientGeometry Dim oDiagonalLine As SketchLine 'the diagonal line in the rectangle Dim oOriginPoint As SketchPoint Dim oOrigin As WorkPoint Set oPartDoc = ThisApplication.ActiveDocument If oPartDoc.SketchActive = True Then 'check to ensure you have a sketch active Set oCompDef = oPartDoc.ComponentDefinition ' Set a reference to the component definition. Set oSketch = oCompDef.Sketches.Item(oCompDef.Sketches.count) XVal = 3 'set this to half the horizontal size you want the rectangle to be IN CENTIMETERS YVal = 2 'set this to half the vertical size you want the rectangle to be IN CENTIMETERS bFoundOrigin = False Set oTransGeom = ThisApplication.TransientGeometry 'Set a reference to the transient geometry object. If oSketch.SketchPoints.count > 0 Then 'try to find if the origin has been projected already For count = 1 To oSketch.SketchPoints.count If oSketch.SketchPoints(count).Geometry.X = 0 And oSketch.SketchPoints(count).Geometry.Y = 0 Then bFoundOrigin = True 'if you have found the origin, keep a ref to it Exit For End If Next End If With oTransGeom 'Draw the 2-point rectangle Set oRectLines = oSketch.SketchLines.AddAsTwoPointRectangle(.CreatePoint2d(-XVal, -YVal), .CreatePoint2d(XVal, YVal)) Set oDiagonalLine = oSketch.SketchLines.AddByTwoPoints(.CreatePoint2d(XVal, -YVal), .CreatePoint2d(-XVal, YVal)) oDiagonalLine.Construction = True With oSketch.GeometricConstraints Call .AddCoincident(oDiagonalLine.StartSketchPoint, oRectLines(1)) Call .AddCoincident(oDiagonalLine.StartSketchPoint, oRectLines(2)) Call .AddCoincident(oDiagonalLine.EndSketchPoint, oRectLines(3)) Call .AddCoincident(oDiagonalLine.EndSketchPoint, oRectLines(4)) End With If bFoundOrigin = False Then Set oOrigin = oCompDef.WorkPoints.Item(1) Set oOriginPoint = oSketch.AddByProjectingEntity(oOrigin) With oSketch.GeometricConstraints Call .AddMidpoint(oOriginPoint, oDiagonalLine) End With Else With oSketch.GeometricConstraints Call .AddMidpoint(oSketch.SketchPoints(count), oDiagonalLine) End With End If End With Else MsgBox "There is no sketch active. Operation Terminated.", vbCritical End If End If End Sub
Hi kalpesh_43
Additionally there is this:
http://www.mcadforums.com/forums/viewtopic.php?f=34&t=11365
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com