-1

I try load line type by using excel VBA as:

Call acadDoc.ModelSpace.Linetypes.Load("HIDDEN", "acad.lin")
Or
Set acadLineTypes = acadDoc.ModelSpace.Linetypes.Load("HIDDEN", "acad.lin")

but impossible.

Community
  • 1
  • 1

1 Answers1

0

The following was reworked from an example at Linetype Property (ActiveX).

Sub Example_Linetype()
    ' This example searches for the linetype Hidden. If it is
    ' not found, it is added from the acad.lin file. Then a
    ' line is created and changed to the Hidden linetype.

    ' Search the linetypes collection for the Hidden linetype.
    Dim entry As AcadLineType
    Dim found As Boolean
    found = False
    For Each entry In acadDoc.Linetypes
        If StrComp(entry.name, "HIDDEN", 1) = 0 Then
            found = True
            Exit For
        End If
    Next
    If Not (found) Then acadDoc.Linetypes.Load "HIDDEN", "acad.lin"

    ' Create the line
    Dim lineObj As AcadLine
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double
    startPoint(0) = 1#: startPoint(1) = 1#: startPoint(2) = 0#
    endPoint(0) = 4#: endPoint(1) = 4#: endPoint(2) = 0#
    Set lineObj = acadDoc.ModelSpace.AddLine(startPoint, endPoint)

    ' Change the linetype of the line
    lineObj.Linetype = "HIDDEN"
    ZoomAll

End Sub
  • Thanks Jeeped so much! I do as your post. It's perfect! I change: acadDoc.ModelSpace.Linetypes.Load "HIDDEN", "acad.lin" into: acadDoc.Linetypes.Load "HIDDEN", "acad.lin" so, Everything is OK. – Nghia Chau Jun 28 '18 at 05:34
  • @jeeped do you have autoCAD or is this just your general (EXPANSIVE) VBA knowledge? – Forward Ed Aug 17 '18 at 00:14
  • @jeeped in the line start and endpoint lines where you are defining the coordinates, what does the # and the : do? I am guessing the : is the same as an end of line or carriage return – Forward Ed Aug 17 '18 at 00:54
  • @ForwardEd, Last version of AutoCAD I personally owned was 10 and the AutoLisp actually led me into database development. AutoCAD is all vector based; you don't draw a line so much as give a start and end point in 3 dimensions (and assign properties like thickness, layer, etc) so given the op's lack of research it was pretty easy to find a solution. –  Aug 17 '18 at 06:14