AutoCAD drawing modification

AutoCAD drawing modification

Anonymous
Not applicable
246 Views
0 Replies
Message 1 of 1

AutoCAD drawing modification

Anonymous
Not applicable

Hi,

 

I exported my sheet metal flat pattern to an AutoCAD drawing in order to send it to our laser cutting supplier. Before I send it to our supplier, I'm able using AutoCAD VBA to select all circles (holes) too small for laser cutting (related to material thickness) and replace them with yellow center marks automatically which will be engraved rather than cut

 

Here is my AutoCAD VBA code:

 

Sub DWG_Treatment()

Dim myTitle As String
myTitle = "DWG Treatment"

Dim myFilename As String
Dim myLength As Integer
Dim myPtPosi As Integer
Dim myUnderPosi As Integer
Dim Thickness As String

Dim maxRad As Double

Dim obj As AcadObject
Dim circ_obj As AcadCircle
Dim cpoint As Variant
Dim oSpace As AcadBlock
Dim oLine As AcadLine

'Get Thickness from filename
myFilename = ThisDrawing.Name
myLength = Len(myFilename)
myPtPosi = InStrRev(myFilename, ".")
myUnderPosi = InStrRev(myFilename, "_")
Thickness = Left(myFilename, myPtPosi - 1)
myLength = Len(Thickness)
Thickness = Right(Thickness, myLength - myUnderPosi)

'Set holes to replace with center marks according to Thickness
Select Case Thickness
    Case 0.0359     '20 GA
        maxRad = 0.03 / 2
    Case 0.0478     '18 GA
        maxRad = 0.035 / 2
    Case 0.0598     '16 GA
        maxRad = 0.04 / 2
    Case 0.0747     '14 GA
        maxRad = 0.05 / 2
    Case 0.1046     '12 GA
        maxRad = 0.07 / 2
    Case 0.1196     '11 GA
        maxRad = 0.08 / 2
    Case 0.1875
        maxRad = 0.125 / 2
    Case 0.25
        maxRad = 0.187 / 2
    Case 0.3125
        maxRad = 0.25 / 2
    Case 0.375
        maxRad = 0.25 / 2
    Case 0.5
        maxRad = 0.375 / 2
    Case 0.625
        maxRad = 0.437 / 2
    Case 0.75
        maxRad = 0.563 / 2
    Case 0.875
        maxRad = 0.625 / 2  'Information according to JIT Laser
    Case 1
        maxRad = 0.75 / 2
    Case Else   'Not supposed to happen
        MsgBox "Contact CAD programmer. Specify error code: 170316.1555.", vbExclamation, myTitle
        Exit Sub
End Select

'Circles treatment
For Each obj In ThisDrawing.ModelSpace
    If TypeOf obj Is AcadCircle Then
        Set circ_obj = obj
        If circ_obj.Radius <= 0.105 Then
            circ_obj.color = acYellow
            
            cpoint = circ_obj.Center
            
            Dim p1(0 To 2) As Double
            Dim p2(0 To 2) As Double
            Dim p3(0 To 2) As Double
            Dim p4(0 To 2) As Double
            
            p1(0) = cpoint(0): p1(1) = cpoint(1) - 0.25: p1(2) = cpoint(2)
            p2(0) = cpoint(0): p2(1) = cpoint(1) + 0.25: p2(2) = cpoint(2)
            p3(0) = cpoint(0) - 0.25: p3(1) = cpoint(1): p3(2) = cpoint(2)
            p4(0) = cpoint(0) + 0.25: p4(1) = cpoint(1): p4(2) = cpoint(2)
            
            With oSpace
                Set oLine = ThisDrawing.ModelSpace.AddLine(p1, p2)
                oLine.color = acYellow
                Set oLine = ThisDrawing.ModelSpace.AddLine(p3, p4)
                oLine.color = acYellow
            End With
            
            circ_obj.Delete
        End If
    End If
    
    ThisDrawing.Regen (acAllViewports)
Next obj

End Sub

 

Is it possible to do the same AutoCAD drawing treatment within Inventor using VBA and/or iLogic?

 

Is it possible to do this treatment within Inventor before I generate my AutoCAD DWG?

 

Thanks,

0 Likes
247 Views
0 Replies
Replies (0)