Jump to content

define an attribute with LockPosition on through dxf code '(280 . 1)


Recommended Posts

Posted (edited)

Hello!

 

I've tried to define an attribute with LockPosition on through dxf code and does not work.

 

(entMake '((0 . "BLOCK") (2 . "PunctT") (70 . 2) (8 . "0") (10 0 0 0) (6 . "ByLayer") (62 . 256)  ) ;_ end of e 
  . . .
(entMake (list '(0 . "ATTDEF") lStrPn '(10 0 0 0) '(70 . 0) '(1 . "") '(2 . "DENUMIRE") '(3 . "Dati DENUMIRE Punct  : ")
'(40 . 1.5) '(11 0.5 1. 0) '(72 . 0) '(74 . 2) '(6 . "ByLayer") '(7 . "Arial") '(62 . 256) [color="red"]'(280 . 1)[/color] ) )

(entMake (list '(0 . "ATTDEF")  ..... [color="red"]'(280 . 1)[/color] ) )
(entMake (list '(0 . "ATTDEF")  ..... [color="red"]'(280 . 1)[/color] ) )
. . .
(entMake '((0 . "EndBlk")) ) ;_ end of e

 

Note:

DXF code 280 , is not available for AutoCAD version 2006 or lower.

 

It requires the same sequence '(280 . 1) when inserting block ?

 


  (entMake (list '(0 . "Insert") '(2 . "PunctT") lStrPs '(66 . 1) (list 10 x y z) lScBpX  lScBpY  lScBpZ) ) ; insert
. . .
  (entMake (list '(0 . "ATTRIB") (list 10 x y z) lStrPh (cons 1 text) '(2 . "COTA")  (list 11 x y z)  [color="red"]'(280 . 1)[/color]) ) ; set
. . .
  (entMake '((0 . "SeqEnd")) ) ; End


 

Does anyone have any ideas?

 

Thanks in advance,

Costin

Edited by Costinbos77
  • 2 months later...
Posted

No one has any idea ?

 

This part of dxf code '(280 . 1) should be before or after other special sequences ?

Posted

Are you stuck using only dxf codes? If not, why not use the properties and methods available through visual lisp?

Posted (edited)

Because when you define objects with different properties, it's faster and easier to use DXF codes .

 

With Visual Lisp have to write more code program.

In some cases it is easier to use Visual Lisp, for example to change properties : the layer or color or line type etc .

 

Does anyone have a lisp with DXF codes , that defines blocks with attributes blocked ( LockPosition = On ) ?

Edited by Costinbos77
Posted

activeX argument

Height, Mode, Prompt, InsertionPoint, Tag, Value

(vla-addattribute
 (vla-get-modelspace(vla-get-activedocument(vlax-get-acad-object)))
   1.0
acAttributeModeConstant ; <--see comment [color="red"]*mode[/color]
"Prompt"
 (vlax-3d-point '(0.0 0.0 0.0)); InsertionPoint
 "Tag"
 "Value"
 )

*mode

acAttributeModeInvisible

acAttributeModeConstant

acAttributeModeVerify

acAttributeModePreset

 

command: _att

;same in dialog *mode

 

 

variable:

(setvar "AFLAGS" 16) ;Lock position in block

 

All info by HELP document

Posted (edited)

Can't be from an AutoCAD variable "AFLAGS" , setting must be for an individual attribute, not global for entire drawing .

 

(setq attributeObj (vla-AddAttribute modelSpace attHeight attMode attPrompt insertionPoint attTag attValue))

(vla-Put-LockPosition attributeObj 1) ; 1=:vlax-True

 

See the difference ?

 

Left side = unlocked ; Right side = Locked

Attributes Block.jpg

Attribute Locked Position.jpg

Attributes Block.dwg

Edited by Costinbos77
Posted

clone dxf

(setq lst (entget locked))
; then delete "locked" attrib 
(entmakex lst)

cons more dxf index

eg:100 etc..

Posted

Very interesting!

 

I defined block with attributes by DXF code .

I set the option vla-Put-LockPosition through Visual Lisp.

(setq blockP (vla-Item Blocks "PunctT") )
(forEach e '(3 4 5 6) (if (vlax-Property-Available-P (setq attO (vla-Item blockP e)) "LockPosition") 
(vla-Put-LockPosition attO :vlax-True) (alert "No  !") ) ) ;_ end of f

 

But all the blocks inserted by the program are not LockPosition.

 

Only the inserted manually.

 

But if it explodes blocks that seem to not be blocked, it is found that the attributes are locked (LockPosition = Yes).

 

Very strange!

Attributes Block 2.dwg

Posted
Very interesting!

 

But if it explodes blocks that seem to not be blocked, it is found that the attributes are locked (LockPosition = Yes).

 

Very strange!

 

sorry costinbos77,

we have no luck.. another word Attribute LockPosition is a Defination.

 

- source from Help document -

*AttributeReference = An object containing text that links to a block.

 

Attribute object = An object appearing as a text string that describes the characteristics of an attribute reference.

 

object.LockPosition Property

Boolean; read-write for Attribute object,

read only for *AttributeReference object

:facepalm:

  • 4 months later...
Posted (edited)

See this !

 

Sorry it's not working !

Edited by Costinbos77
  • 3 years later...
Posted (edited)

 

 Hello again , after a while .

 

I find something , but not all that I need .

 

So , to define a block with attributes and with the property   LockPosition  = On , using dxf codes , it is mandatory to put ALL the 100 codes , as :

 '(100 . "AcDbEntity") , '(100 . "AcDbText") , (100 . "AcDbAttributeDefinition") and to follow the sequence .

 

The code '(280 . 1) or (vla-Put-LockPosition attO acLock) is not mandatory in the block definition , only if you want to be available for a manual insertion of the block as well .

 

vla-Put-LockPosition it is an individual property for every Attribute , it is not a general property of the block with attributes . So , the same block can have few attributes with LockPosition = on and few attributes with LockPosition = off .

 

 But it is mandatory in the insertion definition , otherwise , the Attributes will not have LockPosition = on . 

(defun c:TestPP ()
(prinC "\n  TestPP  :  V  :  1 . 04 . 2019  ;")
 (if (tblSearch "Block" "PxT")
  (princ "\n  Block  Existed !")
  (progn ; Define Block
   (setVar "TextStyle" "Standard")
   (vl-CmdF "_.Purge" "_A" "" "_N")
   (command "_.Layer" "_N" "Name L" "_C" 1 "Name L" "")

   (if (tblSearch "Style" "ArialT") T (vl-CmdF "_.Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ;
 
   (entMake '((0 . "BLOCK") (2 . "PxT") (70 . 2) (8 . "0") (10 0 0 0) (6 . "ByLayer") (62 . 256) (4 . "Made by Me"))  ) ; end of e
   (entMake (list '(0 . "Circle") '(8 . "0") '(62 . 256) '(6 . "ByLayer") '(10 0 0 0) (cons 40 0.25) ) ) ; end of e

   (entMake (list '(0 . "AttDef") '(100 . "AcDbEntity") (cons 8 "0 Name") '(62 . 256) '(6 . "ByLayer") ;'(67 . 0)
                  '(100 . "AcDbText") '(10 0 0 0) '(40 . 1.5) '(1 . "N") '(50 . 0) '(41 . 1) '(51 . 0) '(7 . "ArialT") '(71 . 0) '(72 . 0) 
                         '(11 0.5 +1.0 0) '(210 0.0 0.0 1.0)
                  '(100 . "AcDbAttributeDefinition") '(280 . 0) '(3 . "Point Name") '(2 . "NAME") '(70 . 0) '(73 . 0) '(74 . 2) '(280 . 1) ) ) ; end of e                     '(100 . "AcDbXrecord") 

   (entMake '((0 . "EndBlk") (8 . "0")) ) ; end of e
   (prinC "\n   Block  with  Attributes  DEFINED  :  PxT  ;") ; end of p
  ) ; else
 ) ; if

 (setq i 0)
 (repeat 10 ; Inserting 10 Blocks with Attribute
  (entMake (list '(0 . "Insert") '(2 . "PxT") '(8 . "0") '(66 . 1) (cons 10 (trans (list i i i) 1 0)) '(50 . 0) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0)) ) ; inserare Bloc

  (entMake (list '(0 . "ATTRIB") '(100 . "AcDbEntity") '(8 . "Name L") '(67 . 0) ;'(6 . "ByLayer") ;'(62 . 256) '(67 . 0) ;0 = MSpace ;
                 '(100 . "AcDbText") (list 10 i i i) '(40 . 1) (cons 1 (ItoA i)) '(50 . 0) '(41 . 1.0) '(51 . 0.0) '(7 . "ArialT") '(71 . 0)
                       (cons 72 0) (cons 11 (trans (list i i i) 1 0)) ;'(210 0.0 0.0 1.0)
                 '(100 . "AcDbAttribute") '(280 . 0) '(2 . "NAME") '(70 . 0) '(73 . 0) (cons 74 2) '(280 . 1) )  ) ; set Attribute
  
  (entMake '((0 . "SeqEnd") (8 . "0")) ) ; End Insert Block !

  (setq i (1+ i))  
 ) ; r

 (prinC (strCat "\n   Inserted  :  " (ItoA i) "  ;"))
 (prinC "\n   TestPP  :  END  ;") (prinC)
) ; defun

 

And this property LockPosition    , can't be changed  with visual lisp for inserted blocks , only for the definition of a block :

(vla-Put-LockPosition atV :vlax-True) ; is not working for insertion only for DEFINITION !!!

(vlax-dump-object a1V T)
; IAcadAttributeReference: AutoCAD Attribute Reference Interface
; Property values:
;   Alignment = 8
;   Application (RO) = #<VLA-OBJECT IAcadApplication 000000013f6551a8>
;   Backward = 0
;   Constant (RO) = 0
;   Document (RO) = #<VLA-OBJECT IAcadDocument 00000000412b9318>
;   EntityTransparency = "ByLayer"
;   FieldLength = 0
;   Handle (RO) = "1256"
;   HasExtensionDictionary (RO) = 0
;   Height = 0.3
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 00000000342a6cd8>
;   InsertionPoint = (532320.0 181410.0 0.0)
;   Invisible = 0
;   Layer = "0 Name"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   LockPosition (RO) = 0
;   Material = "ByLayer"
;   MTextAttribute = 0
;   MTextAttributeContent = ""
;   MTextBoundaryWidth = 0.0
;   MTextDrawingDirection = 5
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 43
;   ObjectName (RO) = "AcDbAttribute"
;   ObliqueAngle = 0.0
;   OwnerID (RO) = 44
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   ScaleFactor = 1.0
;   StyleName = "ArialT"
;   TagString = "NAME"
;   TextAlignmentPoint = (532321.0 181410.0 0.0)
;   TextGenerationFlag = 0
;   TextString = "1000"
;   Thickness = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 00000000342a6d90>
;   UpsideDown = 0
;   Visible = -1
; Methods supported:
;   ArrayPolar (3)

Because :   LockPosition (RO) = 0 ;

 

 

Block with Attr.jpg

 

The problem is now ,  if I delete all the contain and PURGE the dwg file ,  if i am repeating to define an insert my block with attributes Pxt ,  the TaxtStyle   ArialT  is creating a problem , and can't be used by the block .  Pictures attached :

 

Points 2.jpg

 

The TextStyle ArialT it is available , but not set on the attributes .

 

If I save this drawing and reopen it , the points are looking like this :

 

Points 3.jpg

 

The TextStyle ArialTopo is coming Active (as in the definition of the block ) , but all the attributes have the same Justification = Bottom Left

So , the problem is the insertion ( cod 72 and 74 ) or TextStyle definition ?

 

If I keep the TextStyle ArialTopo preserved in the drawing , as current Text Style or  used somewhere else , are NO problems . 

 

Any idea ? 

 

I create TestPP for testing .

 

 

Edited by Costinbos77

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...