Dim Errors in Model by VBA Code

Dim Errors in Model by VBA Code

Anonymous
Not applicable
677 Views
4 Replies
Message 1 of 5

Dim Errors in Model by VBA Code

Anonymous
Not applicable

Hi All,

 

I am using below code to create a Rectangle 4 mm X 3 mm x 1 mm, I am using mm template but the model shows 40 mm X 30 mm x 10 mm.

Anything wrong in my code, please someone guide me to understand this type of situation.

 

Private Sub CommandButton1_Click()

    Dim oProjectMgr As DesignProjectManager

    Set oProjectMgr = ThisApplication.DesignProjectManager

    Dim oTemplatesPath As String

   oTemplatesPath = "C:\Program Files\Autodesk\Inventor 2009\Inventor 2009\Templates\FB\AES_Standard.ipt"

    Dim oPartDoc As PartDocument

Set oPartDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, oTemplatesPath, True)

    Dim oCompDef As PartComponentDefinition

    Set oCompDef = oPartDoc.ComponentDefinition

    Dim oSketch As PlanarSketch

    Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))

    Dim oTransGeom As TransientGeometry

    Set oTransGeom = ThisApplication.TransientGeometry

    Dim oRectangleLines As SketchEntitiesEnumerator

    Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _

                                oTransGeom.CreatePoint2d(0,0), _

                                oTransGeom.CreatePoint2d(4,3))

    Dim oProfile As Profile

    Set oProfile = oSketch.Profiles.AddForSolid

    Dim oExtrude As ExtrudeFeature

    Set oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent( _

                        oProfile, 1, kNegativeExtentDirection, kJoinOperation)

 

Thanks & Regards,

S.Sekar

 

0 Likes
678 Views
4 Replies
Replies (4)
Message 2 of 5

nmunro
Collaborator
Collaborator

Internally, Inventor uses cm for all distances, radians for all angles. Look up the UnitsOfMeasure interface

 

        


https://c3mcad.com

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi,

 

Yes Thanks a lot, Please let me know how to change all dim to mm insted of cm.

 

Thanks & Regards,

S.Sekar

0 Likes
Message 4 of 5

skyngu
Collaborator
Collaborator

1 cm = 10 mm

Autodesk Inventor Professional 2019
0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi Jcneal,

 
Well thanks, how to code this to get mm valus while giving co-ordinates.
For example:
co-ordinates (4,3) the actual sketch shows 40mm X 30 mm rectangle.
 
Actually we need co-ordinates (4,3) as 4 mm X 3 mm rectangle sketch.
0 Likes