*X## blocks created

Discussion in 'AutoCAD' started by Yves, Feb 10, 2004.

  1. Yves

    Yves Guest

    Hi,

    I have a macro that creates blocks with attributs.

    And it allways creates blocks that I can purge, they are named *X14, *X15,
    *X16 etc.

    I can't figure where nor why those blocks are created.

    Here is part of the code :

    Public Sub drawCartouche(pt1() As Double, pt2() As Double)
    Dim objblock As AcadBlock, InsPT(0 To 2) As Double, objTmp As Object
    Dim ptText(0 To 2) As Double, minY As Double, maxX As Double
    Dim strBlkName As String
    minY = pt2(1)
    maxX = pt2(0)
    Dim TitreCart(0 To 3) As String, cartTag(0 To 3) As String

    TitreCart(0) = "Coordonnées :"
    TitreCart(1) = "Révisé par :"
    TitreCart(2) = "Dessiné par :"
    TitreCart(3) = "SNRC :"
    cartTag(0) = "Coord"
    cartTag(1) = "REV"
    cartTag(2) = "Dess"
    cartTag(3) = "SNRC"


    InsPT(0) = 0: InsPT(1) = 0: InsPT(2) = 0
    'la cartouche (block) n'existe pas
    Set objblock = ThisDrawing.Blocks.Add(InsPT, "Cartouche")
    'ThisDrawing.PaperSpace.InsertBlock
    'cartouche régulière carte 80X100
    pt1(0) = pt2(0) - 130
    pt1(1) = pt2(1) + 75
    Set objTmp = Rectangle(pt1, pt2, "Cartouche")
    'ajoute au block
    Set objPline = objblock.AddPolyline(objTmp.Coordinates)
    pt1(1) = pt2(1) + 7
    For i = 0 To 2
    pt1(1) = pt1(1) + 7
    pt2(1) = pt1(1)
    'Set objTmp = Ligne(Pt1, Pt2, "Cartouche")
    Set objLine = objblock.AddLine(pt1, pt2)
    Next
    Set objLine = Nothing
    'revient au point de départ en y
    pt1(1) = minY
    pt1(1) = pt1(1) + 55
    pt2(1) = pt1(1)
    'ajoute au block
    Set objLine = objblock.AddLine(pt1, pt2)
    pt1(0) = pt2(0) - 130 / 2
    pt2(0) = pt1(0)
    pt1(1) = pt1(1) - 55
    pt2(1) = pt1(1) + 28
    'ajoute au block
    Set objLine = objblock.AddLine(pt1, pt2)
    pt1(0) = pt1(0) - 130 / 2
    pt1(1) = pt1(1) + 7
    pt2(1) = pt1(1)
    'ajoute au block
    Set objLine = objblock.AddLine(pt1, pt2)
    'texte de la cartouche
    Dim cartText(0 To 3) As String
    With frmCadre
    cartText(0) = .txtCart1
    cartText(1) = .cmbDessinePar
    cartText(2) = .CmbRevisePar
    cartText(3) = .txtCart4
    End With
    ptText(0) = pt1(0) + 3
    'ici
    ptText(1) = minY + 3.5
    Dim objAttr As AcadAttribute
    For i = 0 To 3
    Set objText = objblock.AddText(TitreCart(i), ptText, 2.5)
    With objText
    .Alignment = acAlignmentMiddleLeft
    .TextAlignmentPoint = ptText
    .Update
    End With
    ptText(0) = ptText(0) + 25
    'Set objAttr = ThisDrawing.PaperSpace.AddAttribute(2.5,
    acAttributeModeNormal, "", ptText, "tag", "Value")
    Set objAttr = objblock.AddAttribute(2.5, acAttributeModeNormal, "",
    ptText, cartTag(i), cartText(i))
    With objAttr
    .Alignment = acAlignmentMiddleLeft
    .TextAlignmentPoint = ptText
    .Update
    End With
    'Call Texte(cartText(i), ptText, 2.5, "cartouche")
    ptText(0) = ptText(0) - 25
    ptText(1) = ptText(1) + 7
    Next

    ptText(1) = ptText(1) - 7
    ptText(0) = ptText(0) + 65
    'nom de fichier
    Set objAttr = objblock.AddAttribute(1.5, acAttributeModeNormal, "",
    ptText, "NomFichier", frmCadre.txtNomFichier)
    With objAttr
    .Alignment = acAlignmentMiddleLeft
    .TextAlignmentPoint = ptText
    .Update
    End With
    'Échelle
    ptText(0) = maxX - 32.5
    ptText(1) = minY + 3.5
    Dim txtEchelle As String
    txtEchelle = "1 : " & frmCadre.txtScale
    Set objAttr = objblock.AddAttribute(1.5, acAttributeModeNormal, "",
    ptText, "Echelle", txtEchelle)
    With objAttr
    .Alignment = acAlignmentCenter
    .TextAlignmentPoint = ptText
    .Update
    End With

    ptText(1) = minY + 43.8
    ptText(0) = maxX - 65
    Set objAttr = objblock.AddAttribute(5.4, acAttributeModeNormal, "",
    ptText, "Projet", frmCadre.txtProjet)
    With objAttr
    .Alignment = acAlignmentCenter
    .TextAlignmentPoint = ptText
    .Update
    End With
    ptText(1) = minY + 34.8
    Set objAttr = objblock.AddAttribute(4.5, acAttributeModeNormal, "",
    ptText, "Titre2", frmCadre.txtTitre)

    With objAttr
    .Alignment = acAlignmentCenter
    .TextAlignmentPoint = ptText
    .Update
    End With
    'logo Cambior
    ptText(1) = minY + 59.8
    Set objBlockRef = ThisDrawing.PaperSpace.InsertBlock(InsPT, "Cartouche",
    1, 1, 1, 0)
    strBlkName = "N:\exp\general\dessins\divers\blocks\camblogo.dwg"
    Set objBlockRef = objblock.InsertBlock(ptText, strBlkName, 12, 12, 12,
    0)

    End Sub
     
    Yves, Feb 10, 2004
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.