Message 1 of 1
Working with DWG underlay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
We have a customer project that we would like to use DWG underlay for. From our initial investigations however using an iLogic-friendly version of this VBA sample:
Inventor 2022 Help | ImportedDWGComponent Creation | Autodesk
Dim oDoc As PartDocument
oDoc = ThisDoc.Document
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition
Dim oRefComponents As ReferenceComponents
oRefComponents = oCompDef.ReferenceComponents
' Create a ImportedComponentDefinition based on an AutoCAD file. Dim oImportedCompDef As ImportedComponentDefinition
oImportedCompDef = oRefComponents.ImportedComponents.CreateDefinition("C:\path\to\our\drawing\filename.dwg")
Dim oImportedDWGDef As ImportedDWGComponentDefinition
If oImportedCompDef.Type = kImportedDWGComponentDefinitionObject Then
oImportedDWGDef = oImportedCompDef
Else
Return
End If
Dim oMatrix As Matrix
oMatrix = ThisApplication.TransientGeometry.CreateMatrix
oMatrix.SetTranslation(ThisApplication.TransientGeometry.CreateVector(0, 0, 10))
oImportedDWGDef.Transformation = oMatrix
' Create the ImportedComponent
Dim oImportedComponent As ImportedComponent
oImportedComponent = oRefComponents.ImportedComponents.Add(oImportedDWGDef)
Dim oImportedDWGComponent As ImportedDWGComponent
If oImportedComponent.Type = kImportedDWGComponentObject Then
oImportedDWGComponent = oImportedComponent
Dim oSk As PlanarSketch
oSk = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
' Get the DWGBlockDefinition for model space.
Dim oDWGModelSpaceDef As DWGBlockDefinition = oImportedDWGComponent.ModelSpaceDefinition
' Project DWG entities to planar sketch.
Dim oDWGEntity As DWGBlockReference
For Each oDWGEntity In oDWGModelSpaceDef.BlockReferences
'MsgBox("I am a point")
' MessageBox.Show("Block Name: " & oDWGEntity.Definition.Parent.)
' Call oSk.AddByProjectingEntity(oDWGEntity)
Next
End If
doesn't seem to present us with anything that useful when looping through the BlockReferences contained within the Underlay .dwg file.
Have I missed something obvious or perhaps another method to interrogate any potential blocks contained within the modelspace with a view to filtering on a specific AutoCAD block name and grabbing its position(s)..?
----------------------------------------------------------------
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example