.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Default Block Attributes

6 REPLIES 6
Reply
Message 1 of 7
cadcamm99
496 Views, 6 Replies

Default Block Attributes

I can insert the block with my program. However I don't know how to accept the default values for the tags.  I do not want to edit the attributes, I just want to accept the defaults.

6 REPLIES 6
Message 2 of 7
arcticad
in reply to: cadcamm99

Just set the system variables ATTDIA, and ATTREQ to 0 When you insert the block.

Remember to set them back to the previous setting when done.

---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 3 of 7
cadcamm99
in reply to: arcticad

That does not work for a program.

Message 4 of 7
cadcamm99
in reply to: cadcamm99

got it. I had to explode the block.

Message 5 of 7
Anonymous
in reply to: cadcamm99

That doesn't seem right.  If you explode the block, then it is no longer a block, and no reason to have attributes in the first place.  If that is what you want, then cool, but if not, then maybe if you post the code, people could help you out with a better solution.

Message 6 of 7
Anonymous
in reply to: cadcamm99

En la guia de Autodesk hay un ejemplo:

 

 

<CommandMethod("AddBlockRef2")> _
    Public Sub AddBlockRef2()
        ' Obtener el documento y la base de datos activos
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
 
        ' Obyener el nombre del bloque
        Dim acPr As PromptResult
        acPr = acDoc.Editor.GetString(ControlChars.Lf & "Indique el nombre del bloque: ")
 
        If acPr.Status <> PromptStatus.OK Then
            Return
        End If
 
        ' Iniciar una transaccion
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
 
            ' Abrir la tabla para bloques en modo lectura
            Dim acBlkTbl As BlockTable
            acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
 
 
            ' Comprobar si el bloque existe
            If acBlkTbl.Has(acPr.StringResult) Then
                ' Abrir el registro del bloque de Espacio Modelo para escritura
                Dim acBlkTblRec As BlockTableRecord
                acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                                OpenMode.ForWrite)
 
                ' Obtener una referencia del bloque
                Dim acBlk As BlockTableRecord = acTrans.GetObject( _
                acBlkTbl.Item(acPr.StringResult), OpenMode.ForRead, False)
 
                ' Crear una referencia a bloque
                Dim acBlkRef As New BlockReference(New Point3d(50, 50, 0), acBlk.ObjectId)
 
                ' Rotar 45º
                ' 45 *(Math.PI/180)
                acBlkRef.Rotation = 0.785
                ' Factor de escala
                acBlkRef.ScaleFactors = New Scale3d(50)
 
                ' Añadir el nuevo objeto al registro de la tabla para bloques
                ' y a la transaccion
                acBlkTblRec.AppendEntity(acBlkRef)
                acTrans.AddNewlyCreatedDBObject(acBlkRef, True)
 
                ' Si el bloque contiene atributos, añadirlos a la referencia a bloque
                If acBlk.HasAttributeDefinitions Then
                    For Each acObjId As ObjectId In acBlk
                        Dim acObj As DBObject = acTrans.GetObject(acObjId, OpenMode.ForRead, False)
                        Dim acAttDef As AttributeDefinition = TryCast(acObj, AttributeDefinition)
 
                        If acAttDef IsNot Nothing Then
                            If Not acAttDef.Constant Then
                                ' Crear una referencia de atributo
                                Dim acAttRef As AttributeReference = New AttributeReference
 
                                acAttRef.SetAttributeFromBlock(acAttDef, acBlkRef.BlockTransform)
 
                                ' Esto solo para AutoCAD 2008 o superior
                                ' Si el valor es texto de mutiples lineas
                                If acAttDef.IsMTextAttributeDefinition Then
                                    acAttRef.UpdateMTextAttribute()
                                End If
 
                                acAttRef.TextString = acAttDef.TextString
 
                                ' Agregar la referencia de atributo a la 
                                ' referencia a bloque y a la transaccion
                                acBlkRef.AttributeCollection.AppendAttribute(acAttRef)
                                acTrans.AddNewlyCreatedDBObject(acAttRef, True)
 
                            End If
                        End If
                    Next
                End If
 
                ' Confirmar los cambios
                acTrans.Commit()
            End If
 
        End Using
    End Sub

 

 

Message 7 of 7
cadcamm99
in reply to: Anonymous

I guess the block I was inserting was already a block and created a nested block.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost