Вы находитесь на странице: 1из 59

8.10.

2014

Autodesk Inventor API. /2D

Autodesk Inventor API. /2D


< Autodesk Inventor API.


( ,
..), .
. 2D .

1 2D
2 2D
2.1 2D
2.2 2D
3
3.1
3.2
3.3
4
5
5.1 SketchPoint
5.1.1
5.1.2
5.1.3
5.1.4
5.2 SketchLine
5.2.1
5.2.2
5.2.3
5.3 SketchCircle
5.4 SketchArc
5.5 SketchEllipse
5.6 SketchEllipticalArc
5.7 SketchSpline
5.8 SketchFixedSpline
5.9 SketchOffsetSpline
5.10 SketchImage
5.11 SketchTextBox
5.12
5.12.1 Sketch.OffsetSketchEntitiesUsingDistance
5.12.2 Sketch.OffsetSketchEntitiesUsingPoint
6
6.1 2D
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2D

1/59

8.10.2014

Autodesk Inventor API. /2D

6.1.1
6.2
6.2.1 DiameterDimConstraint
6.2.2 EllipseRadiusDimConstraint
6.2.3 OffsetDimConstraint
6.2.4 RadiusDimConstraint
6.2.5 TangentDistanceDimConstraint
6.2.6 ThreePointAngleDimConstraint
6.2.7 TwoLineAngleDimConstraint
6.2.8 TwoPointDistanceDimConstraint
7

2D

Sketches
PartComponentDefinition.

.
Sketches.Count.
Item .
Sketches.Item(2) .
.
Sketches.Count, .
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2D

2/59

8.10.2014

Autodesk Inventor API. /2D

, , Sketches .Item("")
.
Sketches .
Add AddWithOrientation.


,
. , ,
, 3D .
.
X Y. ,
2D .
.

, .
, , , , , ,
, .
, ,
.
2D .
2D . , ,
. : , ,
, .
.

, ,
. ,
.
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2D

3/59

8.10.2014

Autodesk Inventor API. /2D

API
. , API
, ,
.
.

.
. , ,
1, 1, 2,
3, 4 ,
, 5.
5 .
, .

1, .
,
.
.
- Line,
2 1.
. ,
.
2 :
.
:
2 2 .
4 3.
, 4
3 1.
4 .
5 4.
1
.
2.
.

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2D

4/59

8.10.2014

Autodesk Inventor API. /2D

11
.
, API. API
. -,
.
. API
. .
, API ,
. , , ,
. ,

.

,
. ,
,
. ,
.
.

. API
, ,
API.
API.

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2D

5/59

8.10.2014

Autodesk Inventor API. /2D

SketchLines AddByTwoPoints,
.
AddByTwoPoints(StartPoint As Object, EndPoint As Object) As SketchLine

, "Object".
Point2d, SketchPoint. Point2d
. Point2d,
SketchPoint,
. SketchPoint,
.
, API
. ,
. ,
- . , .
Point2d.
, .
() TransientGeometry.
.
'
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry

Point2d,
.
Dim oCoord1 As Point2d
Set oCoord1 = oTransGeom.CreatePoint2d(0, 0)
Dim oCoord2 As Point2d
Set oCoord2 = oTransGeom.CreatePoint2d(5, 0)

SketchLine.
Point2d. .
.
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2D

6/59

8.10.2014

Autodesk Inventor API. /2D

Dim oLines(1 To 4) As SketchLine


Set oLines(1) = oSketch.SketchLines.AddByTwoPoints(oCoord1, oCoord2)

.
, (5,3):
Set oCoord1 = oTransGeom.CreatePoint2d(5, 3)
Set oLines(2) = oSketch.SketchLines.AddByTwoPoints( _
oLines(1).EndSketchPoint, _
oCoord1)

. Point2d,
2.
Set oCoord1 = oTransGeom.CreatePoint2d(4, 3)
Set oCoord2 = oTransGeom.CreatePoint2d(4, 4)
Dim oArc As SketchArc
Set oArc = oSketch.SketchArcs.AddByCenterStartEndPoint( _
oCoord1, _
oLines(2).EndSketchPoint, _
oCoord2)

Point2d:
Set oCoord1 = oTransGeom.CreatePoint2d(0, 4)
Set oLines(3) = oSketch.SketchLines.AddByTwoPoints( _
oArc.EndSketchPoint, _
oCoord1)

,
.
Set oLines(4) = oSketch.SketchLines.AddByTwoPoints( _
oLines(1).StartSketchPoint, _
oLines(3).EndSketchPoint)

. .
, ,
.
. .
' 1
Call oSketch.GeometricConstraints.AddHorizontal(oLines(1))
' 1 2
Call oSketch.GeometricConstraints.AddPerpendicular( _
oLines(1), oLines(2))
' 2
Call oSketch.GeometricConstraints.AddTangent(oLines(2), oArc)
' 3
Call oSketch.GeometricConstraints.AddTangent(oLines(3), oArc)
' 1 3
Call oSketch.GeometricConstraints.AddParallel(oLines(1), oLines(3))
' 2 4
Call oSketch.GeometricConstraints.AddParallel(oLines(4), oLines(2))
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2D

7/59

8.10.2014

Autodesk Inventor API. /2D

.
.
.
Point2d, .
, , .
, ,
.
, API
. ,
.
.

2D
Sketches.
Add AddWithOrientation.

2D
.
Public Function Add( _
ByVal PlanarEntity As Object, _
Optional ByVal UseFaceEdges As Boolean = False _
) As PlanarSketch

:
PlanarEntity , 2D .
, .
UseFaceEdges , ,
,
. ,
. Add,
False. .. .


.
.
Public Sub AddSketch_1()
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2D

8/59

8.10.2014

Autodesk Inventor API. /2D

' '
' , .
Dim oCompDef As PartComponentDefinition
Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' ,
' , ( :)
Dim oFace As Face
Set oFace = oCompDef.SurfaceBodies.Item(1).Faces.Item(1)
' . Add
' .
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oFace, True)
'
oSketch.Name = " "
End Sub

. :

, ,
. ,
, .
On Error Resume Next
'
oSketch.Name = " "
If Err Then
MsgBox " ." & vbNewLine & _
" ."
Exit Sub
End If

, ,
:

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2D

9/59

8.10.2014

Autodesk Inventor API. /2D

. Add, , .
, oFace.SurfaceType . ,
kPlaneSurface, Add.
Public Sub AddSketch_2()
' '
' , .
Dim oCompDef As PartComponentDefinition
Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' ,
' , ( :)
Dim oFace As Face
Set oFace = oCompDef.SurfaceBodies.Item(1).Faces.Item(1)

' , .
' .
If oFace.SurfaceType = kPlaneSurface Then
' . .
' Add
' .
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oFace, True)

On Error Resume Next


'
oSketch.Name = " "
If Err Then
MsgBox " ." & vbNewLine & _
" ."
Exit Sub
End If
Else
MsgBox " "
End If
End Sub

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

10/59

8.10.2014

Autodesk Inventor API. /2D

:

.

2D

, . 2D
Sketches AddWithOrientation.
.
Public Function AddWithOrientation( _
ByVal PlanarEntity As Object, _
ByVal AxisEntity As Object, _
ByVal NaturalAxisDirection As Boolean, _
ByVal AxisIsX As Boolean, _
ByVal Origin As Object, _
Optional ByVal UseFaceEdges As Boolean = False _
) As PlanarSketch

PlanarEntity
, .
AxisEntity
, ,
X Y .
, AxisIsX.
, .
NaturalAxisDirection
. TRUE, X Y
AxisEntity, FALSE, .
AxisIsX
. TRUE, ,
AxisEntity, X, FALSE, Y.
Origin
, .
: (vertex), .
.
UseFaceEdges
. ,
,
. FALSE ,
. , PlanarEntity ,
, .. , .
' 2D
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

11/59

8.10.2014

Autodesk Inventor API. /2D

' Sketches.AddWithOrientation
'
' ,
' .
'
Public Sub AddOrientedSketch()
'
'
Dim oCompDef As PartComponentDefinition
Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' ( )
' , ,
' .
Dim oFace As Face
Set oFace = oCompDef.SurfaceBodies.Item(1).Faces.Item(1)
' . .
' X .
Dim oEdge As Edge
Set oEdge = oFace.Edges.Item(2)
' ,
'
Dim oVertex As Vertex
Set oVertex = oEdge.StartVertex
' .
'
' oEdge X.
' oFace .
' oVertex.
'
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.AddWithOrientation( _
oFace, _
oEdge, _
True, _
True, _
oVertex, _
True)
' #1. ,
' .
' .
oSketch.Name = " 1"
' (0,0)
' 10
Dim oCircle As SketchCircle
Set oCircle = oSketch.SketchCircles.AddByCenterRadius( _
ThisApplication.TransientGeometry.CreatePoint2d(0, 0), 1)
' X 10 .
Call oSketch.SketchLines.AddByTwoPoints( _
oCircle.CenterSketchPoint, _
ThisApplication.TransientGeometry.CreatePoint2d(1, 0))
' #5.
'
' ( ).
' - ,
' FALSE.
Set oFace = oCompDef.SurfaceBodies.Item(1).Faces.Item(5)
Set oEdge = oFace.Edges.Item(1)
Set oSketch = oCompDef.Sketches.AddWithOrientation( _
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

12/59

8.10.2014

Autodesk Inventor API. /2D

oFace, _
oEdge, _
True, _
True, _
oCompDef.WorkPoints.Item(1))
' #2
oSketch.Name = " 2"
' (0,0)
' 10
Set oCircle = oSketch.SketchCircles.AddByCenterRadius( _
ThisApplication.TransientGeometry.CreatePoint2d(0, 0), 1)
' X 10 .
Call oSketch.SketchLines.AddByTwoPoints( _
oCircle.CenterSketchPoint, _
ThisApplication.TransientGeometry.CreatePoint2d(1, 0))
End Sub



"Sketch1" .
, , .
Public Sub StartSketchEdit()
' 2D
' .
Dim oSketches As PlanarSketches
Set oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches
' 2D "Sketch1"
' ,
' .
On Error Resume Next
Dim oSketch As PlanarSketch
Set oSketch = oSketches.Item("Sketch1")
If Err Then
MsgBox " ""Sketch1"" ." & vbNewLine & _
" ""StartSketchEdit"" ."
Exit Sub
End If
On Error GoTo 0
'
' (Edit mode)
oSketch.Edit
End Sub


XY ,
(0,0)
(5,5). .

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

13/59

8.10.2014

Autodesk Inventor API. /2D

Public Sub EditSketch_1()


'
Dim oCompDef As PartComponentDefinition
Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' XY
Dim oPlane As WorkPlane
Set oPlane = oCompDef.WorkPlanes.Item(3)
'
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oPlane)
'
oSketch.Edit
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
' (0,0) (5,5)
' !
Dim oLine As SketchLine
Set oLine = oSketch.SketchLines.AddByTwoPoints( _
oTg.CreatePoint2d(0, 0), _
oTg.CreatePoint2d(5, 5))
'
oSketch.ExitEdit
End Sub

, ,
, . ,
, .
Public Sub EditSketch_2()
'
Dim oCompDef As PartComponentDefinition
Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' XY
Dim oPlane As WorkPlane
Set oPlane = oCompDef.WorkPlanes.Item(3)
'
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oPlane)
'
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
' (0,0) (5,5)
' !
Dim oLine As SketchLine
Set oLine = oSketch.SketchLines.AddByTwoPoints( _
oTg.CreatePoint2d(0, 0), _
oTg.CreatePoint2d(5, 5))
End Sub
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

14/59

8.10.2014

Autodesk Inventor API. /2D


. , ,

.


, .

YZ .
PlanarEntity.
X Y .
Sub RedefineSketch2dPlane()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition
' 2D
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Item(1)
' YZ
Dim oYZPlane As WorkPlane
Set oYZPlane = oCompDef.WorkPlanes.Item(1)
' ,
oSketch.PlanarEntity = oYZPlane
End Sub

,
.
' .
' ,
' .
Public Sub ChangeSketchPlane()
' .
' .
Dim oCompDef As PartComponentDefinition
Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' .
' , .
' .
Dim oFace As Face
Set oFace = oCompDef.SurfaceBodies.Item(1).Faces.Item(1)
' oFace
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oFace, True)
'
' 10
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

15/59

8.10.2014

Autodesk Inventor API. /2D

Dim oCircle As SketchCircle


Set oCircle = oSketch.SketchCircles.AddByCenterRadius( _
ThisApplication.TransientGeometry.CreatePoint2d(0, 0), 1)
' X 10
Call oSketch.SketchLines.AddByTwoPoints(oCircle.CenterSketchPoint, _
ThisApplication.TransientGeometry.CreatePoint2d(1, 0))

' %%%%% #1 %%%%%


MsgBox "#1: ."
' .
Set oFace = oCompDef.SurfaceBodies.Item(1).Faces.Item(2)
oSketch.PlanarEntity = oFace
MsgBox " : " & _
oSketch.OriginPointGeometry.X & ", " & _
oSketch.OriginPointGeometry.Y & ", " & _
oSketch.OriginPointGeometry.Z & Chr(13) & Chr(13) & _
" ."

' %%%%% #2 %%%%%


'
oSketch.OriginPoint = oCompDef.WorkPoints.Item(1)
MsgBox "#2: : " & _
oSketch.OriginPointGeometry.X & ", " & _
oSketch.OriginPointGeometry.Y & ", " & _
oSketch.OriginPointGeometry.Z & Chr(13) & Chr(13) & _
" ."
MsgBox " X: " & _
oSketch.AxisEntityGeometry.Direction.X & ", " & _
oSketch.AxisEntityGeometry.Direction.Y & ", " & _
oSketch.AxisEntityGeometry.Direction.Z

' %%%%% #3 %%%%%


MsgBox "#3: X ."

' .
oSketch.AxisEntity = oFace.Edges.Item(2)

MsgBox " X: " & _


oSketch.AxisEntityGeometry.Direction.X & ", " & _
oSketch.AxisEntityGeometry.Direction.Y & ", " & _
oSketch.AxisEntityGeometry.Direction.Z

' %%%%% #4 %%%%%


MsgBox "#4: ."
'
oSketch.NaturalAxisDirection = False
MsgBox " X: " & _
oSketch.AxisEntityGeometry.Direction.X & ", " & _
oSketch.AxisEntityGeometry.Direction.Y & ", " & _
oSketch.AxisEntityGeometry.Direction.Z

' %%%%% #5 %%%%%


http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

16/59

8.10.2014

Autodesk Inventor API. /2D

MsgBox "#5: , X Y."


' X.
oSketch.AxisIsX = False
End Sub


PlanarSketch.Delete.
, .
PanarSketch.Dependents. , ..
PanarSketch.Dependents.Count > 0, .
, .
.
HasReferenceComponent, TRUE,
. ReferenceComponent
-.
. ,
Sketch1.
.
Public Sub DeleteSketch()
' Set a reference to the Sketches collection. This assumes
' that a part document containing a sketch is active.
'
' .
Dim oSketches As PlanarSketches
Set oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches
' "Sketch1".
'
On Error Resume Next
Dim oSketch As PlanarSketch
Set oSketch = oSketches.Item("Sketch1")
If Err Then
MsgBox " ""Sketch1"" ."
Exit Sub
End If
On Error GoTo 0
'
If oSketch.Dependents.Count > 0 Then
MsgBox " , " & vbNewLine & _
" ."
Else
'
oSketch.Delete
End If
End Sub


http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

17/59

8.10.2014

Autodesk Inventor API. /2D

SketchPoint

SketchPoints . SketchPoints.Count
. Add
:
Public Function Add( _
ByVal Point As Point2d, _
Optional ByVal HoleCenter As Boolean = True _
) As SketchPoint

Point2d .
HoleCenter ,
( ) . , ,
.
.
:
Public Sub SketchPointsTest()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
Dim oCoord As Point2d
Dim oPoint As SketchPoint
' #1
Set oCoord = oTg.CreatePoint2d(1, 1)
Set oPoint = oSketch.SketchPoints.Add(oCoord, True)
' #2
Set oCoord = oTg.CreatePoint2d(2, 2)
Set oPoint = oSketch.SketchPoints.Add(oCoord, False)
MsgBox " : " & _
oSketch.SketchPoints.Count
End Sub

Geometry SketchPoint Point2d,


(x,y) :
x = SketchPoint.Geometry.X
y = SketchPoint.Geometry.Y


http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

18/59

8.10.2014

Autodesk Inventor API. /2D

MoveTo MoveBy. ,
Call oPoint.MoveTo(oTg.CreatePoint2d(1, 2))

oPoint x=10 , y=20 .

Call oPoint.MoveBy(oTg.CreateVector2d(-1, 0))

oPoint 10 .

.
, .


L oPoint1 oPoint2
SketchPoint.DistanceTo:
L = oPoint1.Geometry.DistanceTo(oPoint2.Geometry)

, , :
With oPoint1.Geometry
x1 = .X
y1 = .Y
End With
With oPoint2.Geometry
x2 = .X
y2 = .Y
End With
L = Sqr((x2 - x1) ^ 2 + (y2 - y1) ^ 2)

60% DistanceTo. ,
, ,

L = Sqr((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)),

:
.
SketchPoint.DistanceTo.


SketchPoint.Merge .
, ,
Merge .
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

19/59

8.10.2014

Autodesk Inventor API. /2D

SketchLine

SketchLines .
AddByTwoPoints
AddAsTwoPointRectangle
AddAsThreePointRectangle

AddByTwoPoints
AddByTwoPoints:
Public Function AddByTwoPoints( _
ByVal StartPoint As Object, _
ByVal EndPoint As Object _
) As SketchLine

StartPoint StartPoint ,
. Point2d, (x,y),
SketchPoint.
, .
1. AddByTwoPoints
Public Sub FirstLine()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oCoord(1 To 2) As Point2d
Set oCoord(1) = oTg.CreatePoint2d(1, 1)
Set oCoord(2) = oTg.CreatePoint2d(2, 2)
'
Dim oLine As SketchLine
Set oLine = oSketch.SketchLines.AddByTwoPoints(oCoord(1), oCoord(2))
'
MsgBox " (): " & _
oSketch.SketchLines(oSketch.SketchLines.Count).Length * 10
End Sub

10 ,
.

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

20/59

8.10.2014

Autodesk Inventor API. /2D

AddAsTwoPointRectangle

, X Y .
. ,
AddAsTwoPointRectangle .
:
Public Function AddAsTwoPointRectangle( _
ByVal CornerPointOne As Object, _
ByVal CornerPointTwo As Object _
) As SketchEntitiesEnumerator

Point2d SketchPoint.
/ , ,
.
SketchEntitiesEnumerator,
SketchLine.
Public Sub AddAsTwoPointRectangle_Example()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oCoord(1 To 2) As Point2d
Set oCoord(1) = oTg.CreatePoint2d(1, 1)
Set oCoord(2) = oTg.CreatePoint2d(4, 2)
'
Dim oRectangleLines As SketchEntitiesEnumerator
Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle(oCoord(1), oCoord(2))

Dim St As String
Dim SkEnt As SketchEntity
For Each SkEnt In oRectangleLines
St = St & SkEnt.Type & vbNewLine
Next
MsgBox St
End Sub

MsgBox 83896064,
kSketchLineObject.

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

21/59

8.10.2014

Autodesk Inventor API. /2D

,
.
AddAsTwoPointRectangle .
AddAsThreePointRectangle

.
:
Public Function AddAsThreePointRectangle( _
ByVal BasePointOne As Object, _
ByVal BasePointTwo As Object, _
ByVal HeightPoint As Point2d _
) As SketchEntitiesEnumerator

, .
Point2d,
SketchPoint.
.

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

22/59

8.10.2014

Autodesk Inventor API. /2D

, .
Point2d, .
.
, .
.

SketchEntitiesEnumerator.
.
, .
Public Sub AddAsThreePointRectangle_Example()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oCoord(1 To 3) As Point2d
Set oCoord(1) = oTg.CreatePoint2d(1, 1)
Set oCoord(2) = oTg.CreatePoint2d(4, 2)
Set oCoord(3) = oTg.CreatePoint2d(-1, 2)
'
Dim oRectangleLines As SketchEntitiesEnumerator
Set oRectangleLines = oSketch.SketchLines.AddAsThreePointRectangle( _
oCoord(1), _
oCoord(2), _
oCoord(3))
'
Dim St As String
Dim SkEnt As SketchEntity
For Each SkEnt In oRectangleLines
St = St & SkEnt.Type & vbNewLine
Next
MsgBox St
End Sub
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

23/59

8.10.2014

Autodesk Inventor API. /2D


Centerline
Construction
StartSketchPoint
EndSketchPoint
Length
Parent


, , .
UnitVector2d. ,
.

dim UVec2d as UnitVector2d


set UVec2d = oSketchLine.Geometry.LineSegment2d.Direction


. , , ,
Direction.

SketchCircle
PlanarSketch SketchCircle.
SketchCircles. ,
Count , Item
.
.
API :
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

24/59

8.10.2014

Autodesk Inventor API. /2D

AddByCenterRadius ;
AddByThreePoints
Point2d.
(20,20) 10 .
SketchCircle:
SketchCircle.Geomery Circle2d,
Point2d;
SketchCircle.Radius ;
SketchCircle.Area , .
Public Sub AddCircle()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oCoord As Point2d
Set oCoord = oTg.CreatePoint2d(2, 2)
' R=10
Dim oCircle As SketchCircle
Set oCircle = oSketch.SketchCircles.AddByCenterRadius(oCoord, 1)
'
oCircle.Construction = True
With oCircle
MsgBox " (.): " & Round(oCircle.Area * 100, 2) _
& vbNewLine & _
" (): (" & .Geometry.Center.x * 10 & " , " & _
.Geometry.Center.y * 10 & " )" & vbNewLine & _
" (): " & .Radius * 10
End With
End Sub

SketchArc
PlanarSketch SketchArc.
SketchArcs. Count
, Item
. .
API :
AddByCenterStartSweepAngle , ,
.

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

25/59

8.10.2014

Autodesk Inventor API. /2D

Public Sub AddArc_1()


'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oCoord As Point2d
Set oCoord = oTg.CreatePoint2d(-1, 1)
'C
Dim oArc As SketchArc
Set oArc = oSketch.SketchArcs.AddByCenterStartSweepAngle(oCoord, 2, 0, 1)
End Sub

AddByCenterStartEndPoint ,
. , ,
CounterClockwise.
.
.
Private Sub AddArc_2()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oP(1 To 3) As Point2d
Set oP(1) = oTg.CreatePoint2d(-4, 0)
Set oP(2) = oTg.CreatePoint2d(0, -2)
Set oP(3) = oTg.CreatePoint2d(4, 0)
'C
Dim oArc As SketchArc
Set oArc = oSketch.SketchArcs.AddByCenterStartEndPoint(oP(2), oP(1), oP(3))
End Sub

AddByFillet .
, ,
.
Public Sub AddArc_3()
'
Dim oSketch As PlanarSketch
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

26/59

8.10.2014

Autodesk Inventor API. /2D

Set oSketch = ThisApplication.ActiveEditObject


'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oLine1 As SketchLine
Dim oLine2 As SketchLine
Set oLine1 = oSketch.SketchLines.AddByTwoPoints( _
oTg.CreatePoint2d(-4, -2), _
oTg.CreatePoint2d(2, 1))
Set oLine2 = oSketch.SketchLines.AddByTwoPoints( _
oTg.CreatePoint2d(-3, 3), _
oTg.CreatePoint2d(2, 2.5))
'
Dim oCoord1 As Point2d
Set oCoord1 = oLine1.EndSketchPoint.Geometry
Dim oCoord2 As Point2d
Set oCoord2 = oLine2.EndSketchPoint.Geometry
' = 12
Dim R As Double
R = 1.2
'C
Dim oArc As SketchArc
Set oArc = oSketch.SketchArcs.AddByFillet(oLine1, oLine2, R, oCoord1, oCoord2)
End Sub

AddByThreePoints (, ).
.
Private Sub AddArc_4()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oP(1 To 3) As Point2d
Set oP(1) = oTg.CreatePoint2d(-4, 0)
Set oP(2) = oTg.CreatePoint2d(0, -2)
Set oP(3) = oTg.CreatePoint2d(4, 0)
'C
Dim oArc As SketchArc
Set oArc = oSketch.SketchArcs.AddByThreePoints(oP(1), oP(3), oP(2))
End Sub

, .

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

27/59

8.10.2014

Autodesk Inventor API. /2D

, (StartSketchPoint EndSketchPoint,
) .
, .. .
Delete() .
SketchArc .
, Length() .

SketchEllipse
PlanarSketch SketchEllipse.
SketchEllipses. Count
, Item
. .
Add (SketchPoint
Point2d), ( UnitVector2d) (Double).
Private Sub AddEllips()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oCoord As Point2d
Set oCoord = oTg.CreatePoint2d(1, 1)
'
'
Dim oVector As UnitVector2d
Set oVector = oTg.CreateUnitVector2d(1, 1)
'C
Dim oEllips As SketchEllipse
Set oEllips = oSketch.SketchEllipses.Add(oCoord, oVector, 4, 2)
End Sub

SketchEllipticalArc
PlanarSketch SketchEllipticalArc.
SketchEllipses. Count
, Item
. .
Add
(SketchPoint Point2d), ( UnitVector2d)
(), ().
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

28/59

8.10.2014

Autodesk Inventor API. /2D

Public Sub Add_SketchEllipticalArc()


'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
'
Dim oCenterPoint As Point2d
Set oCenterPoint = oTg.CreatePoint2d(0, 0)
'
'
Dim oMajorAxisVector As UnitVector2d
Set oMajorAxisVector = oTg.CreateUnitVector2d(1, 0)
Dim PI As Double
PI = 4 * Atn(1)

'

Dim MajorRadius As Double


Dim MinorRadius As Double
Dim StartAngle As Double
Dim SweepAngle As Double
MajorRadius = 4
MinorRadius = 2
StartAngle = 3 * PI / 2
SweepAngle = PI / 2
'C
Dim oEArc As SketchEllipticalArc
Set oEArc = oSketch.SketchEllipticalArcs.Add( _
oCenterPoint, _
oMajorAxisVector, _
MajorRadius, _
MinorRadius, _
StartAngle, _
SweepAngle)
'
Dim oTextCoord As Point2d
Set oTextCoord = oTg.CreatePoint2d(-1, -0.5)
'
Dim oEllipseRadiusDim As EllipseRadiusDimConstraint
Set oEllipseRadiusDim = oSketch.DimensionConstraints. _
AddEllipseRadius(oEArc, False, oTextCoord)
End Sub

, .
Delete().
SketchEllipticalArc
. , Length() .

SketchSpline
PlanarSketch SketchSpline.
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

29/59

8.10.2014

Autodesk Inventor API. /2D

SketchSplines. Count
, Item
. .
Add
(SketchPoint Point2d), ObjectCollection.
Point2d,
SketchPoint.
SplineFitPointConstraints.
SplineFitMethodEnum .
:
kSmoothSplineFit
.
kSweetSplineFit
kACADSplineFit , AutoCAD, NURBS
( B-).

' Autodesk Inventor


' .
'
' .
'
Public Sub DrawSketchSpline()
' : ?
If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
MsgBox " ."
Exit Sub
End If
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry
' ,
Dim oFitPoints As ObjectCollection
Set oFitPoints = ThisApplication.TransientObjects.CreateObjectCollection

' .
' .
' .
' "" .
' : (0,0), (2,2), (4,0), (6,4), (7,-1).
Dim oPoints(1 To 5) As Point2d
Set oPoints(1) = oTransGeom.CreatePoint2d(0, 0)
oFitPoints.Add oPoints(1)
Set oPoints(2) = oTransGeom.CreatePoint2d(2, 2)
oFitPoints.Add oPoints(2)
Set oPoints(3) = oTransGeom.CreatePoint2d(4, 0)
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

30/59

8.10.2014

Autodesk Inventor API. /2D

oFitPoints.Add oPoints(3)
Set oPoints(4) = oTransGeom.CreatePoint2d(6, 4)
oFitPoints.Add oPoints(4)
Set oPoints(5) = oTransGeom.CreatePoint2d(7, -1)
oFitPoints.Add oPoints(5)
'
Dim oSpline As SketchSpline
Set oSpline = oSketch.SketchSplines.Add(oFitPoints)
'
oSpline.Closed = True
' Ground
Call oSketch.GeometricConstraints.AddGround(oSpline.FitPoint(3))
'
Dim oNewPoint As Point2d
Set oNewPoint = oTransGeom.CreatePoint2d(8, 8)
Call oSpline.InsertFitPoint(oNewPoint, 5, True)
' #2
Call oSpline.FitPoint(2).MoveTo(oTransGeom.CreatePoint2d(2, 3))
'
oSpline.FitPoint(2).Delete
End Sub

SketchFixedSpline
SketchFixedSpline .
BSplineCurve2d (NURBS B).
SketchFixedSplines . Count
, Item
. .
Add SketchFixedSplines
, BSplineCurve2d.
.
, .
SketchSpline.
ConvertToSpline().
' Autodesk Inventor
'
' (NURB).
' API 3D .
' .
Public Sub SplineByDefinition()
'
' , .
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

31/59

8.10.2014

Autodesk Inventor API. /2D

Dim oCompDef As PartComponentDefinition


Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry
'
Dim oFitPoints As ObjectCollection
Set oFitPoints = ThisApplication.TransientObjects.CreateObjectCollection
' . :
' (0,0), (2,2), (4,0), (6,4).
Dim oPoints(1 To 4) As Point2d
Set oPoints(1) = oTransGeom.CreatePoint2d(0, 0)
oFitPoints.Add oPoints(1)
Set oPoints(2) = oTransGeom.CreatePoint2d(2, 2)
oFitPoints.Add oPoints(2)
Set oPoints(3) = oTransGeom.CreatePoint2d(4, 0)
oFitPoints.Add oPoints(3)
Set oPoints(4) = oTransGeom.CreatePoint2d(6, 4)
oFitPoints.Add oPoints(4)

' #1 X-Y
Dim oSketch1 As PlanarSketch
Set oSketch1 = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
' .
Dim oSpline As SketchSpline
Set oSpline = oSketch1.SketchSplines.Add(oFitPoints)
' , X-Y
Dim oWorkPlane As WorkPlane
Set oWorkPlane = oCompDef.WorkPlanes.AddByPlaneAndOffset(oCompDef.WorkPlanes(3), 2)
' #2 oWorkPlane
Dim oSketch2 As PlanarSketch
Set oSketch2 = oCompDef.Sketches.Add(oWorkPlane)
'
Dim oBSplineCurve2d As BSplineCurve2d
Set oBSplineCurve2d = oSpline.Geometry
'
' .
Dim oFixedSpline As SketchFixedSpline
Set oFixedSpline = oSketch2.SketchFixedSplines.Add(oBSplineCurve2d)
End Sub

SketchOffsetSpline
SketchOffsetSplines
SketchOffsetSpline.
SketchOffsetSpline, ..
, Offset
.
.
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

32/59

8.10.2014

Autodesk Inventor API. /2D

Geometry BSplineCurve2d
(Transient Geometry). GetBSplineData GetBSplineInfo
,
.
,
BSplineCurve2d.Evaluator Curve2dEvaluator
. , , , ,
,
.
ConvertToSpline SketchOffsetSpline SketchSpline,
, .

SketchImage
SketchImage SketchImages .
- Add
SketchImage .
, Point2d.
.
SketchImage
90
, , .
SketchImage . SketchImage
Name.
ReferencedFileDescriptor, ReferencedOLEFileDescriptor.
: ReferencedOLEFileDescriptor.DisplayName
, ReferencedOLEFileDescriptor.FullFileName ,
OLE .
Position Point2d (
).
height width .
Transparent , Visible .
,
: "C:\temp\SampleImage_1.gif"
"C:\temp\SampleImage_2.gif".
Sub SketchImage()
' .
' .
Dim oPartCompDef As PartComponentDefinition
Set oPartCompDef = ThisApplication.ActiveDocument.ComponentDefinition
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

33/59

8.10.2014

Autodesk Inventor API. /2D

'
Dim oSketch As PlanarSketch
Set oSketch = oPartCompDef.Sketches.Item(1)
'
Dim oPoint As Point2d
Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(2, 1)
'
Dim oImage As SketchImage
Set oImage = oSketch.SketchImages.Add( _
"C:\temp\SampleImage_1.gif", _
oPoint, _
True)
oImage.Name = " #1"

'
Set oPoint = ThisApplication.TransientGeometry.CreatePoint2d(2, 10)
Set oImage = oSketch.SketchImages.Add( _
"C:\temp\SampleImage_2.gif", _
oPoint, _
True)
oImage.Name = " #2"

MsgBox oSketch.SketchImages.Item(1).Name & vbNewLine & _


oSketch.SketchImages.Item(2).Name
MsgBox oImage.ReferencedFileDescriptor.DisplayName
MsgBox oImage.ReferencedFileDescriptor.FullFileName
End Sub

Autodesk Inventor , SketchImage


, . .

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

34/59

8.10.2014

Autodesk Inventor API. /2D

BoundaryGeometry Nothing


(SketchLines),

Height and Width

Height Width


() .

Visible

Transparent

Name

( BMP
FullFileName)


SketchImages.Item Item

Item
, .

MirrorHorizontal

MirrorVertical

RotateLeft

RotateRight

Update

SketchTextBox
SketchTextBoxes


.
OffsetSketchEntitiesUsingDistance

OffsetSketchEntitiesUsingPoint
.

Sketch.OffsetSketchEntitiesUsingDistance

.
()
. :

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

35/59

8.10.2014

Autodesk Inventor API. /2D

, .
,
.
,
, .
.
Public Function OffsetSketchEntitiesUsingDistance( _
ByVal SketchEntities As ObjectCollection, _
ByVal OffsetDistance As Double, _
ByVal NaturalOffsetDirection As Boolean, _
Optional ByVal IncludeConnectedEntities As Boolean = False, _
Optional ByVal CreateOffsetConstraints As Boolean = True _
) As SketchEntitiesEnumerator

SketchEntities
ObjectCollection.
,
SketchPoint (offset) .
,
( OffsetDistance NaturalOffsetDirection,
).
,
SketchEntities, IncludeConnectedEntities
False. .
,
:
.
SketchEntities.
,
.
.
,
OffsetSketchEntitiesUsingDistance .
IncludeConnectedEntities TRUE.
, ,
,
.
,
OffsetSketchEntitiesUsingDistance . ,
, ,
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

36/59

8.10.2014

Autodesk Inventor API. /2D

, , , IncludeConnectedEntities
FALSE. TRUE ,
.
OffsetDistance
(
). .

.
NaturalOffsetDirection.
, OffsetDistance NaturalOffsetDirection
offset . ,

( SketchEntities).
NaturalOffsetDirection
.
.
(natural offset direction)
,
.
TRUE
. FALSE . ,
NaturalOffsetDirection ,
.

, , OffsetDistance.
,
SketchEntities.

IncludeConnectedEntities
, ,
.
SketchEntities.
TRUE, SketchEntities
, .
.
,
,
.
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

37/59

8.10.2014

Autodesk Inventor API. /2D

FALSE,
.
SketchEntities. .
.

CreateOffsetConstraints
,
. TRUE, .
FALSE, .
, TRUE, ..
.

,

. ( .

).
OffsetDistance
.

.
( OffsetLines_1)
, (
OffsetLines_2).

' 2D .
'
' .
Public Sub OffsetLines_1()
' - ?
If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
MsgBox " "
Exit Sub
End If
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

38/59

8.10.2014

Autodesk Inventor API. /2D

Dim oCollection As ObjectCollection


Set oCollection = ThisApplication.TransientObjects.CreateObjectCollection
' -
oCollection.Add oSketch.SketchLines.Item(1)
Dim bNaturalOffsetDir As Boolean
Dim IncludeConnectedEntities As Boolean
Dim CreateOffsetConstraints As Boolean
bNaturalOffsetDir = True
'
IncludeConnectedEntities = True '
CreateOffsetConstraints = True
'
' 5
Call oSketch.OffsetSketchEntitiesUsingDistance( _
oCollection, _
0.5, _
bNaturalOffsetDir, _
IncludeConnectedEntities, _
CreateOffsetConstraints)
End Sub

' 2D .
'
' .
Public Sub OffsetLines_2()
' - ?
If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
MsgBox " "
Exit Sub
End If
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oCollection As ObjectCollection
Set oCollection = ThisApplication.TransientObjects.CreateObjectCollection
' ,
oCollection.Add oSketch.SketchLines.Item(1)
oCollection.Add oSketch.SketchLines.Item(2)
oCollection.Add oSketch.SketchLines.Item(3)
oCollection.Add oSketch.SketchLines.Item(4)
Dim bNaturalOffsetDir As Boolean
Dim IncludeConnectedEntities As Boolean
Dim CreateOffsetConstraints As Boolean
bNaturalOffsetDir = True
'
IncludeConnectedEntities = False '
CreateOffsetConstraints = True
'
' 5
Call oSketch.OffsetSketchEntitiesUsingDistance( _
oCollection, _
0.5, _
bNaturalOffsetDir, _
IncludeConnectedEntities, _
CreateOffsetConstraints)
End Sub

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

39/59

8.10.2014

Autodesk Inventor API. /2D

Sketch.OffsetSketchEntitiesUsingPoint
OffsetSketchEntitiesUsingPoint ,

.
:
Public Function OffsetSketchEntitiesUsingPoint( _
ByVal SketchEntities As ObjectCollection, _
ByVal OffsetPoint As Point2d, _
Optional ByVal IncludeConnectedEntities As Boolean = False, _
Optional ByVal CreateOffsetConstraints As Boolean = True _
) As SketchEntitiesEnumerator

SketchEntities, IncludeConnectedEntities CreateOffsetConstraints


, .
OffsetPoint. ,
Offset.
.
.
, .
.

.
Public Sub OffsetLines_3()
' ?
If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
MsgBox " "
Exit Sub
End If
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oCollection As ObjectCollection
Set oCollection = ThisApplication. _
TransientObjects.CreateObjectCollection
'
oCollection.Add oSketch.SketchLines.Item(1)
oCollection.Add oSketch.SketchLines.Item(2)
oCollection.Add oSketch.SketchLines.Item(3)
oCollection.Add oSketch.SketchLines.Item(4)

',
Dim oOffsetPoint As Point2d
Set oOffsetPoint = oSketch.SketchPoints.Item( _
oSketch.SketchPoints.count).Geometry

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

40/59

8.10.2014

Autodesk Inventor API. /2D

'
Call oSketch.OffsetSketchEntitiesUsingPoint( _
oCollection, oOffsetPoint, False, True)
End Sub


2D
GeometricConstraints .
Autodesk Inventor
(geometric constraints), , .. (dimension
constraints). ,
.
GeometricConstraints
( GeometricConstraint)
.
, ,
. .
, (1,1) (2,2),
, ,
.
Sub Test()
'
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oLine As SketchLine
Set oLine = oSketch.SketchLines.AddByTwoPoints( _
oTG.CreatePoint2d(1, 1), _
oTG.CreatePoint2d(2, 2))
'
Dim St As String
Dim oGC As GeometricConstraint
St = St & " : " & oSketch.SketchEntities.Count & vbNewLine
St = St & " : " & oSketch.SketchPoints.Count & vbNewLine
St = St & " : " & oSketch.SketchLines.Count & vbNewLine
St = St & ": " & oSketch.GeometricConstraints.Count
For Each oGC In oSketch.GeometricConstraints
St = St & vbNewLine & "
" & oGC.Type
Next
MsgBox St
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

41/59

8.10.2014

Autodesk Inventor API. /2D

End Sub

:
:
:
:
:

3
2
1
2
83900160
83900160

, 83900160
kCoincidentConstraintObject "Coincident constraint",
.
,
?

. AddByTwoPoints,
Point2d,

. ""
.


AddCoincident
. ,
.
.
SketchPoint.Merge.
AddCollinear
.
, . -
. , .
AddConcentric
, .. .
, , .

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

42/59

8.10.2014

Autodesk Inventor API. /2D

AddEqualLength
.
AddEqualRadius
.
.
AddGround
.
AddHorizontal

.
AddHorizontalAlign
Y-,
.
AddMidpoint
.
AddParallel
/ .
AddPerpendicular
.
.
AddSmooth
(G2-).
AddSymmetry

.
.
AddTangent
.
AddVertical
. .
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

43/59

8.10.2014

Autodesk Inventor API. /2D

AddVerticalAlign
X-,
.

,
.
.

, , ,
GeometricConstraints,
, .. Add.
OffsetConstraint
OffsetConstraint Offset.
Sketch.GeometricConstraints .

OffsetSketchEntitiesUsingDistance OffsetSketchEntitiesUsingPoint Sketch.
.
PatternConstraint
PatternConstraint
. ,
Sketch.GeometricConstraints
.

.

, - .

4015 .
' 4015
'
' .
Public Sub Constraints_1()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oTG As TransientGeometry
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

44/59

8.10.2014

Autodesk Inventor API. /2D

Set oTG = ThisApplication.TransientGeometry


'
Dim i As Integer
Dim oL(1 To 4) As SketchLine
For i = 1 To 4
Set oL(i) = oSketch.SketchLines.Item(i)
Next i

' 1-2-3-4.
' AddCoincident .
' Merge ().
Call oL(1).EndSketchPoint.Merge(oL(2).StartSketchPoint)
Call oL(2).EndSketchPoint.Merge(oL(3).StartSketchPoint)
Call oL(3).EndSketchPoint.Merge(oL(4).StartSketchPoint)
Call oL(4).EndSketchPoint.Merge(oL(1).StartSketchPoint)
'
Call oSketch.GeometricConstraints.AddParallel(oL(1), oL(3))
Call oSketch.GeometricConstraints.AddParallel(oL(2), oL(4))
' 1 2
Call oSketch.GeometricConstraints.AddPerpendicular(oL(1), oL(2))
' ,
' .

' 40 15
' 1.
'
'
Dim oDimPoint As Point2d
Dim X As Double
Dim Y As Double
X = oL(1).Geometry.MidPoint.X
Y = oL(1).Geometry.MidPoint.Y
Set oDimPoint = oTG.CreatePoint2d( _
X + oL(1).Length / 5, _
Y + oL(1).Length / 5)
'
Call oSketch.DimensionConstraints.AddTwoPointDistance( _
oL(1).StartSketchPoint, _
oL(1).EndSketchPoint, _
kAlignedDim, _
oDimPoint, _
False)
' 40 -
oSketch.DimensionConstraints.Item( _
oSketch.DimensionConstraints.Count).Parameter.Value = 4

' 2
X = oL(2).Geometry.MidPoint.X
Y = oL(2).Geometry.MidPoint.Y
Set oDimPoint = oTG.CreatePoint2d( _
X + oL(2).Length / 5, _
Y + oL(2).Length / 5)
Call oSketch.DimensionConstraints.AddTwoPointDistance( _
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

45/59

8.10.2014

Autodesk Inventor API. /2D

oL(2).StartSketchPoint, _
oL(2).EndSketchPoint, _
kAlignedDim, _
oDimPoint, _
False)
oSketch.DimensionConstraints.Item( _
oSketch.DimensionConstraints.Count).Parameter.Value = 1.5
oSketch.Solve '
End Sub

, ,
:
' 1 3
Call oSketch.GeometricConstraints.AddHorizontal(oL(1))
Call oSketch.GeometricConstraints.AddHorizontal(oL(3))
' 2 4
Call oSketch.GeometricConstraints.AddVertical(oL(2))
Call oSketch.GeometricConstraints.AddVertical(oL(4))
' ,
' .


(), API.

DiameterDimConstraint

AddDiameter DimensionConstraints
DiameterDimConstraint.
.
Driven .
,
. .
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

46/59

8.10.2014

Autodesk Inventor API. /2D

.
60
. ,
20 . .
Public Sub DiameterDim()
'
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject

' 1. 30
Dim oCircle As SketchCircle
Set oCircle = oSketch.SketchCircles.AddByCenterRadius( _
oTG.CreatePoint2d(1, 1), 3)
' .
' .
' .
'
Dim oCenter2d As Point2d
Set oCenter2d = oCircle.CenterSketchPoint.Geometry
'
Dim oTextCoord As Point2d
Set oTextCoord = oTG.CreatePoint2d( _
oCenter2d.X + oCircle.Radius, _
oCenter2d.Y + oCircle.Radius)
'
Call oSketch.DimensionConstraints.AddDiameter(oCircle, oTextCoord)
MsgBox " 1. " & _
oCircle.Radius * 20 & " "

' 2. 20
' ,
' .
' .
' - kDiameterDimConstraintObject
Dim oConstr As Object
For Each oConstr In oCircle.Constraints
If oConstr.Type = kDiameterDimConstraintObject Then
oConstr.Parameter.Value = 2
Exit For
End If
Next
oSketch.Solve '
MsgBox " 2. " & _
oCircle.Radius * 20 & " "
End Sub
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

47/59

8.10.2014

Autodesk Inventor API. /2D

EllipseRadiusDimConstraint

AddEllipseRadius DimensionConstraints
EllipseRadiusDimConstraint.

.
Driven .
,
. .
.
, .
.
Public Sub EllipseDim()
'
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject

' 1. 20 40
'
Dim oE As SketchEllipse
'
Dim oCenter2d As Point2d
Set oCenter2d = oTG.CreatePoint2d(2, 2)
'
Dim oMajorVec As UnitVector2d
Set oMajorVec = oTG.CreateUnitVector2d(2, 1)
'
Dim MajorRadius As Double
MajorRadius = 4
'
Dim MinorRadius As Double
MinorRadius = 2
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

48/59

8.10.2014

Autodesk Inventor API. /2D

Set oE = oSketch.SketchEllipses.Add( _
oCenter2d, _
oMajorVec, _
MajorRadius, _
MinorRadius)
' 2.
'
Dim oTextCoord As Point2d
Set oTextCoord = oTG.CreatePoint2d(4.1)
'
Call oSketch.DimensionConstraints.AddEllipseRadius( _
oE, True, oTextCoord, True, False)
'
Set oTextCoord = oTG.CreatePoint2d(6, 5)
'
Call oSketch.DimensionConstraints.AddEllipseRadius( _
oE, False, oTextCoord, True, False)
End Sub

OffsetDimConstraint

OffsetDimConstraint
AddOffset DimensionConstraints
OffsetDimConstraint.
Line .
TextPoint.
, .
Public Function AddOffset( _
ByVal Line As SketchLine, _
ByVal Entity As SketchEntity, _
ByVal TextPoint As Point2d, _
ByVal LinearDiameter As Boolean, _
Optional ByVal Driven As Boolean = False _
) As OffsetDimConstraint

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

49/59

8.10.2014

Autodesk Inventor API. /2D

Line .
Entity , .
TextPoint.
LinearDiameter , .
Entity , Entity
. Entity ,
Line.
Driven .
,
. .


. ,
35 .
Public Sub OffsetDim()
'
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oLine(1 To 2) As SketchLine
Set oLine(1) = oSketch.SketchLines.Item(1)
Set oLine(2) = oSketch.SketchLines.Item(2)
' .
' ,
'
If Not oLine(1).Geometry.Direction.IsParallelTo( _
oLine(2).Geometry.Direction) Then
MsgBox " "
Exit Sub '
End If

'
Dim oTextCoord As Point2d
Set oTextCoord = oTG.CreatePoint2d(1, 1)
'
Call oSketch.DimensionConstraints.AddOffset( _
oLine(1), _
oLine(2), _
oTextCoord, _
True, _
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

50/59

8.10.2014

Autodesk Inventor API. /2D

False)
oLine(2).Centerline = True

' 35
oSketch.DimensionConstraints.Item( _
oSketch.DimensionConstraints.Count).Parameter.Value = 3.5
oSketch.Solve
End Sub

RadiusDimConstraint

AddRadius DimensionConstraints
RadiusDimConstraint.
.
Driven .
,
. .
.

RadiusDimConstraint.
Public Sub RadiusDim()
'
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject

' 1. 30
Dim oCircle As SketchCircle
Set oCircle = oSketch.SketchCircles.AddByCenterRadius( _
oTG.CreatePoint2d(1, 1), 3)
' .
' .
' .
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

51/59

8.10.2014

Autodesk Inventor API. /2D

'
Dim oCenter2d As Point2d
Set oCenter2d = oCircle.CenterSketchPoint.Geometry
'
Dim oTextCoord As Point2d
Set oTextCoord = oTG.CreatePoint2d( _
oCenter2d.X + oCircle.Radius, _
oCenter2d.Y + oCircle.Radius)
'
Call oSketch.DimensionConstraints.AddRadius(oCircle, oTextCoord)
MsgBox " " & _
oCircle.Radius * 10 & " "
End Sub

TangentDistanceDimConstraint

AddTangentDistance DimensionConstraints
TangentDistanceDimConstraint
.
,
. .
.
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

52/59

8.10.2014

Autodesk Inventor API. /2D


.
, , LinearDiameter
. True, .
LinearDiameter , .
Driven .
,
. .
.
,
TangentDistanceDimConstraint.
Private Sub TangentDim()
'
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
' 15 (-20 , 20 )
Dim oCircle1 As SketchCircle
Set oCircle1 = oSketch.SketchCircles.AddByCenterRadius( _
oTG.CreatePoint2d(-2, 2), 1.5)
' 10 (20 , 30 )
Dim oCircle2 As SketchCircle
Set oCircle2 = oSketch.SketchCircles.AddByCenterRadius( _
oTG.CreatePoint2d(2, 3), 1)
'
Dim oProximityPoint As Point2d
Set oProximityPoint = oTG.CreatePoint2d(0.2, 2)
Dim oSketchPoint As SketchPoint
Set oSketchPoint = oSketch.SketchPoints.Add(oProximityPoint, False)
'
Dim oTextCoord, ProximityPoint As Point2d
Set oTextCoord = oTG.CreatePoint2d(0, 0)
'
Call oSketch.DimensionConstraints.AddTangentDistance( _
oCircle1, _
oCircle2, _
oProximityPoint, _
oProximityPoint, _
oTG.CreatePoint2d(1, 1), _
False)
End Sub

ThreePointAngleDimConstraint

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

53/59

8.10.2014

Autodesk Inventor API. /2D

AddThreePointAngle DimensionConstraints
ThreePointAngleDimConstraint , .
.
, Point2d
.
.
Driven .
,
. .
:
Private Sub ThreePointAngleDimConstraint()
'
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
Dim oP(1 To 3) As SketchPoint
Set oP(1) = oSketch.SketchPoints.Add( _
oTG.CreatePoint2d(0.5, 1), False)
Set oP(2) = oSketch.SketchPoints.Add( _
oTG.CreatePoint2d(0.2, 0.2), False)
Set oP(3) = oSketch.SketchPoints.Add( _
oTG.CreatePoint2d(1.5, 0.4), False)
'
Dim oTextCoord As Point2d
Set oTextCoord = oTG.CreatePoint2d(2, 2)
'C
Call oSketch.DimensionConstraints.AddThreePointAngle( _
oP(1), oP(2), oP(3), _
oTextCoord, _
False)
End Sub

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

54/59

8.10.2014

Autodesk Inventor API. /2D

. ThreePointAngleDimConstraint.
, ,
.

. 83906304,
kThreePointAngleDimConstraintObject.
Private Sub ThreePointAngleDimConstraint_2()
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Debug.Print oSketch.DimensionConstraints.Count
'
Dim oDim As DimensionConstraint
Set oDim = oSketch.DimensionConstraints.Item(1)
Debug.Print oDim.Type
End Sub

Immediate Window VBA Ctrl-G.


TwoLineAngleDimConstraint

AddTwoLineAngle DimensionConstraints
TwoLineAngleDimConstraint , .
, Point2d
.
.
Driven .
,
. .
:
Private Sub TwoLineAngleDimConstraint()
'
Dim oTg As TransientGeometry
Set oTg = ThisApplication.TransientGeometry
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

55/59

8.10.2014

Autodesk Inventor API. /2D

'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject

'
Dim oL1 As SketchLine
Dim oL2 As SketchLine
Set oL1 = oSketch.SketchLines.AddByTwoPoints( _
oTg.CreatePoint2d(1, 1), _
oTg.CreatePoint2d(2, 1.2))
Set oL2 = oSketch.SketchLines.AddByTwoPoints( _
oTg.CreatePoint2d(1, 1.5), _
oTg.CreatePoint2d(2, 2))
'
Dim oTextCoord As Point2d
Set oTextCoord = oTg.CreatePoint2d(3, 2)
'C
Call oSketch.DimensionConstraints.AddTwoLineAngle( _
oL1, oL2, oTextCoord, False)

'
Dim oDim As DimensionConstraint
Set oDim = oSketch.DimensionConstraints.Item( _
oSketch.DimensionConstraints.Count)
MsgBox " : " & oDim.Type
End Sub

83906048,
kTwoLineAngleDimConstraintObject.
TwoPointDistanceDimConstraint

AddTwoPointDistance DimensionConstraints
TwoPointDistanceDimConstraint , .
, Orientation
. :

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

56/59

8.10.2014

Autodesk Inventor API. /2D

kHorizontalDim 19201
kVerticalDim

19202

kAlignedDim

19203

Point2d.
Driven .
,
. .
:
Private Sub AngleDim()
'
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oP(1 To 2) As SketchPoint
Set oP(1) = oSketch.SketchPoints.Add( _
oTG.CreatePoint2d(0.5, 1), False)
Set oP(2) = oSketch.SketchPoints.Add( _
oTG.CreatePoint2d(3, 2), False)

'
Dim oTextCoord As Point2d
'C
Set oTextCoord = oTG.CreatePoint2d(1, 3)
Call oSketch.DimensionConstraints.AddTwoPointDistance( _
oP(1), oP(2), kAlignedDim, oTextCoord, False)
Set oTextCoord = oTG.CreatePoint2d(2, 0.5)
Call oSketch.DimensionConstraints.AddTwoPointDistance( _
oP(1), oP(2), kHorizontalDim, oTextCoord, False)
Set oTextCoord = oTG.CreatePoint2d(4, 1.5)
Call oSketch.DimensionConstraints.AddTwoPointDistance( _
oP(1), oP(2), kVerticalDim, oTextCoord, False)

'
Dim oDim As DimensionConstraint
For Each oDim In oSketch.DimensionConstraints
Debug.Print " : " & oDim.Type
Next
End Sub

Immediate Window VBA


: : 83905792 : 83905792 : 83905792
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

57/59

8.10.2014

Autodesk Inventor API. /2D

, , .
83905792 kTwoPointDistanceDimConstraintObject.


, , Color.
R,G,B (Red , Green , Blue
). : 0..255. Opacity
, 0 ( )
1 ( ).
Color CreateColor TransientObjects (
). , ,
Opacity (), 1.
,
OverrideColor Color.
:
Dim oColor As Color
Set oColor = ThisApplication.TransientObjects. _
CreateColor(255, 0, 0) '
oSketch.SketchLines.item(1).OverrideColor = oColor

OverrideColor Nothing ,
.
.
.
.
Private Sub OverrideColor()
'
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
'
Dim oSketch As PlanarSketch
Set oSketch = ThisApplication.ActiveEditObject
'
Dim oL(1 To 3) As SketchLine
Set oL(1) = oSketch.SketchLines.AddByTwoPoints( _
oTG.CreatePoint2d(1, 1), _
oTG.CreatePoint2d(2, 1))
Set oL(2) = oSketch.SketchLines.AddByTwoPoints( _
oL(1).EndSketchPoint, _
oTG.CreatePoint2d(2, 2))
Set oL(3) = oSketch.SketchLines.AddByTwoPoints( _
oL(2).EndSketchPoint, _
oL(1).StartSketchPoint)
'
http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

58/59

8.10.2014

Autodesk Inventor API. /2D

Dim oColor(1 To 3) As Color


Set oColor(1) = ThisApplication.TransientObjects. _
CreateColor(255, 0, 0) '
Set oColor(2) = ThisApplication.TransientObjects. _
CreateColor(0, 255, 0) '
Set oColor(3) = ThisApplication.TransientObjects. _
CreateColor(0, 0, 255) '
'
Dim i As Integer
For i = 1 To 3
oL(i).OverrideColor = oColor(i)
Next i
End Sub

http://ru.wikibooks.org/w/index.php?
title=Autodesk_Inventor_API.__/2D_&oldid=46608
: Autodesk Inventor API.
: 08:12, 27 2009.
Creative Commons Attribution-ShareAlike,
. . .

http://ru.wikibooks.org/wiki/Autodesk_Inventor_API._%D0%9F%D0%B5%D1%80%D0%B2%D1%8B%D0%B5_%D1%88%D0%B0%D0%B3%D0%B8/2

59/59