Inventor API Project All Entities Only Does Some Of Them

Inventor API Project All Entities Only Does Some Of Them

Anonymous
Not applicable
319 Views
1 Reply
Message 1 of 2

Inventor API Project All Entities Only Does Some Of Them

Anonymous
Not applicable

Moved from reference post: Problems Importing .DXF or .DWG files into Inventor

 

Hi please help,

when i try to use API for this Why not project all entities, but just some? Can u help me please?

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 SubCapture1.JPG

 

0 Likes
320 Views
1 Reply
Reply (1)
Message 2 of 2

YuhanZhang
Autodesk
Autodesk

Can you upload the data for us to reproduce the problem if it is not confidential?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes