Import AutoCAD Drawings to Inventor VBA

Import AutoCAD Drawings to Inventor VBA

Anonymous
Not applicable
1,746 Views
2 Replies
Message 1 of 3

Import AutoCAD Drawings to Inventor VBA

Anonymous
Not applicable

Hi,

 

Is there a vba code that will do all these steps (http://blog.ketiv.com/import-autocad-drawings-to-inventor) ?

 

1.Import AutoCAD Drawings to Inventor

2.Using 2D Data to Drive 3D Models

3.And create 3D model from 2D Data

 

 

Thank you

 

 

0 Likes
1,747 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor

"Anything is possible."

 

Is there something out there that does it already? Not that I'm aware of.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 3

Anonymous
Not applicable

plese help,

I use this code for to create an imported DWG component into Inventor part document, and project the DWG entities onto Inventor planar sketch. Why not project all entities, but just some? Thank you very much. Sorry for my english.

 

Used code: 

 

Sub CreateImportedDWGComponentSample()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.Documents.Add(kPartDocumentObject)
    
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oDoc.ComponentDefinition
    
    Dim oRefComponents As ReferenceComponents
    Set oRefComponents = oCompDef.ReferenceComponents
    
    ' Create a ImportedComponentDefinition based on an AutoCAD file.    Dim oImportedCompDef As ImportedComponentDefinition
    Set oImportedCompDef = oRefComponents.ImportedComponents.CreateDefinition("C:\Temp\ACADDWG.dwg")
    
    Dim oImportedDWGDef As ImportedDWGComponentDefinition
    
    If oImportedCompDef.Type = kImportedDWGComponentDefinitionObject Then
        Set oImportedDWGDef = oImportedCompDef
    Else
        End
    End If
    
    Dim oMatrix As Matrix
    Set oMatrix = ThisApplication.TransientGeometry.CreateMatrix
    oMatrix.SetTranslation ThisApplication.TransientGeometry.CreateVector(0, 0, 10)
    
    oImportedDWGDef.Transformation = oMatrix
    
    ' Create the ImportedComponent
    Dim oImportedComponent As ImportedComponent
    Set oImportedComponent = oRefComponents.ImportedComponents.Add(oImportedDWGDef)
    
    Dim oImportedDWGComponent As ImportedDWGComponent
    
    If oImportedComponent.Type = kImportedDWGComponentObject Then
        Set oImportedDWGComponent = oImportedComponent
        
        Dim oSk As PlanarSketch
        Set oSk = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
        
        ' Get the DWGBlockDefinition for model space.        Dim oDWGModelSpaceDef As DWGBlockDefinition
        Set oDWGModelSpaceDef = oImportedDWGComponent.ModelSpaceDefinition
        
        ' Project DWG entities to planar sketch.
        Dim oDWGEntity As DWGEntity
        For Each oDWGEntity In oDWGModelSpaceDef.Entities
         
            Call oSk.AddByProjectingEntity(oDWGEntity)
        Next
    End If
End Sub

 

Capture1.JPG 

0 Likes