TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CAB on September 29, 2004, 10:56:47 PM
-
What if any function is the 71 code in a block and an insert.
The help for Insert says:
70 Column count (optional; default = 1)
71 Row count (optional; default = 1)[/list:u]
Is this only valid if MINSERT blocks? or what?
Help for block says:
70 Block-type flags (bit coded values, may be combined):[/list:u]
No mention of code 71?
The reason I ask is that I have found some BLOCKS with code 71 . 1
when I tried to entmake a copy of the block the entmake was rejected with
message : Invalid field type 71 in (entmake).
-
CAB,
Could you post the drawing with this block? As you've found, the 71 code is only present in Minsert'ed inserts(nad should have a corresponding group 45 for the spacing(R2002, please)
Jeff
-
Jeff,
Can't post the file, sorry.
The INSERT has codes 70, 71, 44, 45 and are all zero.
And the BLOCK has code 71 . 1
Unknown as to what software produced these blocks.
There are two types of column blocks in plan view.
One square tubing and the other an I beam.
You would expect them to be minserted into the drawing.
CAB
-
The BLOCK definition has a code 71??
Interesting. Does it get commented if you run an AUDIT?
-
The BLOCK definition has a code 71??
Interesting. Does it get commented if you run an AUDIT?
Command: _audit
Fix any errors detected? [Yes/No] <N>:
3 Blocks audited
Pass 1 3 objects audited
Pass 2 3 objects audited
Pass 3 100 objects audited
Total errors found 0 fixed 0
Quite a mystery. :)
-
Very mysterious.
I've never heard of a code 71 for block defs.
-
Up until R13, you could convert a standard INSERT into a MINSERT with (entmod) on groups 70, 71, 44, 45. With the addition of group 100 codes all of that changed.
Today a MINSERT cannot be edited back into a single INSERT without a little lisp.
;;;CONVERT ( EXPLODE ) MINSERTS INTO SINGLE INSERTS
;;;05-05-2004 ADD XDATA & ATTRIBS ADDED
;;;05-07-2004 CLEANUP
;;;05-08-2004 PRESET DEFAULTS
;;;05-09-2004 FDI GLOBAL ENAME PASSING
(defun c:exmins (/ def ss en ed fe fl ml an ad al)
(setq def '(("CECOLOR" . "BYLAYER")
("CELTYPE" . "BYLAYER")
("THICKNESS" . 0)
("CELTSCALE" . 1)))
(foreach v def
(if (getvar (car v))
(setvar (car v) (cdr v))))
(if
(not
(and fdi_global_en
(= (type fdi_global_en) 'ENAME)
(entget fdi_global_en)
(= "INSERT" (cdr (assoc 0 (entget fdi_global_en))))
(setq en fdi_global_en)))
(progn
(while (or (not ss)
(> (sslength ss) 1))
(princ "\nSelect A MINSERT To Convert: ")
(setq ss (ssget (list (cons 0 "INSERT")))))
(setq en (ssname ss 0))))
(setq ed (entget en '("*")))
(setq fl '(0 1 2 6 7 8 10 11 39 40 41 42 43 44 45 50 51 62 66 67 70 71 72 73 74 210 -3))
(foreach g fl
(set (read (strcat "g" (itoa g)))
(cdr (assoc g ed)))
(and (assoc g ed)
(not (member g '(-3 44 45 70 71)))
(setq ml (cons (assoc g ed) ml))))
(if (not (assoc 67 ml))
(setq ml (cons (cons 67 0) ml)))
(if g-3 (setq ml (cons (assoc -3 ed) ml)))
(entmake (reverse ml))
(if (= (cdr (assoc 66 ed)) 1)
(progn
(setq an (entnext en))
(while (/= "SEQEND" (cdr (assoc 0 (entget an))))
(setq ad (entget an)
al nil)
(foreach g fl
(and (assoc g ad)
(setq al (cons (assoc g ad) al))))
(entmake (reverse al))
(setq an (entnext an)))
(entmake (list (cons 0 "SEQEND")
(cons 8 "0")))))
(entdel en)
(setvar "OSMODE" 0)
(setvar "CMDECHO" 0)
(setq fe (entlast))
(command "_.UCS" "_W")
(command "_.UCS" "_E" fe)
(cond ((and (> g71 1)
(> g70 1))
(command "_.ARRAY" fe "" "R" g71 g70 g45 g44))
((> g70 1)
(command "_.ARRAY" fe "" "R" 1 g70 g44))
((> g71 1)
(command "_.ARRAY" fe "" "R" g71 1 g45)))
(command "_.UCS" "_W")
(foreach g fl (set (read (strcat "g" (itoa g))) nil))
(setq fdi_global_en nil)
(prin1))
You would conversly have edit the group 100 code ( if they can be ) as well 70, 71 ,45 ,44 to make a MINSERT.
This has been a thorn in my side for a long time as I use MINSERTs a lot.
HTH -David
-
On second look, converting INSERTs to MINSERTs does not require group 100 editing. Acad does it al by itself.
;=======================================================================
; BlkXY.Lsp Jun 03, 1998
; Edit Block X Colomn Values
;================== Start Program ======================================
(princ "\nCopyright (C) 1998, Fabricated Designs, Inc.")
(princ "\nLoading BlkXY v1.0 ")
(setq bx_ nil lsp_file "BlkXY")
;================== For Automated Calling From Another Program =========
(defun bx_auto (ar1 ar2 ar3) ;;;ename space count
(bx_mod ar1 ar2 ar3))
(defun by_auto (ar1 ar2 ar3) ;;;ename space count
(by_mod ar1 ar2 ar3))
;================== Macros =============================================
(defun PDot ()(princ "."))
(defun Beep (/ f)
(and (wcmatch (getvar "PLATFORM") "*DOS*")
(setq f (open "con" "w"))
(write-char '7 f)
(close f)))
(defun Err (e)
(beep)
(princ (strcat "\nError: *** " e " *** "))
(quit))
;================== Sub Routines =======================================
(PDot);++++++++++++ Set Modes & Error ++++++++++++++++++++++++++++++++++
(defun bx_smd ()
(SetUndo)
(setq olderr *error*
*error* (lambda (e)
(while (> (getvar "CMDACTIVE") 0)
(command))
(and (/= e "quit / exit abort")
(princ (strcat "\nError: *** " e " *** ")))
(command "_.UNDO" "_END" "_.U")
(bx_rmd))
bx_var '(
("CMDECHO" . 0) ("MENUECHO" . 0) ("MENUCTL" . 0) ("MACROTRACE" . 0)
("OSMODE" . 0) ("SORTENTS" . 119)("MODEMACRO" . ".")
("BLIPMODE" . 0) ("EXPERT" . 0) ("SNAPMODE" . 1) ("PLINEWID" . 0.0)
("ORTHOMODE" . 1) ("GRIDMODE" . 0) ("ELEVATION" . 0) ("THICKNESS" . 0)
("FILEDIA" . 0) ("FILLMODE" . 0) ("SPLFRAME" . 0) ("UNITMODE" . 0)
("TEXTEVAL" . 0) ("ATTDIA" . 0) ("AFLAGS" . 0) ("ATTREQ" . 1)
("ATTMODE" . 2) ("UCSICON" . 1) ("HIGHLIGHT" . 1) ("REGENMODE" . 1)
("COORDS" . 2) ("DRAGMODE" . 2) ("DIMZIN" . 1) ("PDMODE" . 0)
("CECOLOR" . "BYLAYER") ("CELTYPE" . "BYLAYER")))
(foreach v bx_var
(setq m_v (cons (getvar (car v)) m_v)
m_n (cons (car v) m_n))
(setvar (car v) (cdr v)))
(princ (strcat (getvar "PLATFORM") " Release " (ver)
" - Edit X Col Y Row Block Spacing ....\n"))
(princ))
(PDot);++++++++++++ Return Modes & Error +++++++++++++++++++++++++++++++
(defun bx_rmd ()
(setq *error* olderr)
(mapcar 'setvar m_n m_v)
(command "_.UNDO" "_END")
(prin1))
(PDot);++++++++++++ Set And Start An Undo Group ++++++++++++++++++++++++
(defun SetUndo ()
(and (zerop (getvar "UNDOCTL"))
(command "_.UNDO" "_ALL"))
(and (= (logand (getvar "UNDOCTL") 2) 2)
(command "_.UNDO" "_CONTROL" "_ALL"))
(and (= (logand (getvar "UNDOCTL") 8) 8)
(command "_.UNDO" "_END"))
(command "_.UNDO" "_GROUP"))
(PDot);++++++++++++ Get Entity Name ++++++++++++++++++++++++++++++++++++
(defun GetOne (/ st os)
(setq os (getvar "SNAPMODE") s nil)
(setvar "SNAPMODE" 0)
(while (not st)
(setq st (ssget)))
(while (> (sslength st) 1)
(setq st nil)
(princ "\nOnly 1 At A Time Please\n")
(while (not st)
(setq st (ssget))))
(setvar "SNAPMODE" os)
(setq s (ssname st 0)))
(PDot);++++++++++++ Get Multiple Information Input +++++++++++++++++++++
(defun by_get ()
(graphscr)
(setq row (cdr (assoc 71 bdef))
ysp (cdr (assoc 45 bdef)))
(princ (strcat
"\nInsert Name: "
(cdr (assoc 2 bdef))
(if (cdr (assoc 1 (tblsearch "BLOCK" (cdr (assoc 2 bdef)))))
" - XRef Definition" " ")))
(princ (strcat
"\n Rows: " (itoa row)
" Spaced At: " (rtos ysp)))
(setq row (cdr (assoc 71 bdef))
ysp (cdr (assoc 45 bdef)))
(setq ncnt (getint (strcat "\nNew Column Count <" (itoa row) ">: ")))
(and (not ncnt) (setq ncnt row))
(setq nspc (getdist (cdr (assoc 10 bdef)) (strcat "\nNew Column Spacing <" (rtos ysp) ">: ")))
(and (not nspc) (setq nspc ysp)))
(PDot);++++++++++++ Get Multiple Information Input +++++++++++++++++++++
(defun bx_get ()
(graphscr)
(setq col (cdr (assoc 70 bdef))
xsp (cdr (assoc 44 bdef)))
(princ (strcat
"\nInsert Name: "
(cdr (assoc 2 bdef))
(if (cdr (assoc 1 (tblsearch "BLOCK" (cdr (assoc 2 bdef)))))
" - XRef Definition" " ")))
(princ (strcat
"\n Columns: " (itoa col)
" Spaced At: " (rtos xsp)))
(setq col (cdr (assoc 70 bdef))
xsp (cdr (assoc 44 bdef)))
(setq ncnt (getint (strcat "\nNew Column Count <" (itoa col) ">: ")))
(and (not ncnt) (setq ncnt col))
(setq nspc (getdist (cdr (assoc 10 bdef)) (strcat "\nNew Column Spacing <" (rtos xsp) ">: ")))
(and (not nspc) (setq nspc xsp)))
(PDot);++++++++++++ Modify The Block Row Count +++++++++++++++++++++++++
(defun by_mod (e x c)
(and (= (type e) 'ENAME)
(= "INSERT" (cdr (assoc 0 (entget e))))
(numberp x)
(= (type c) 'INT)
(setq ed (entget e)
ed (subst (cons 45 x) (assoc 45 ed) ed)
ed (subst (cons 71 c) (assoc 71 ed) ed))
(entmod ed)
(entupd e)))
(PDot);++++++++++++ Modify The Block Column Count ++++++++++++++++++++++
(defun bx_mod (e x c)
(and (= (type e) 'ENAME)
(= "INSERT" (cdr (assoc 0 (entget e))))
(numberp x)
(= (type c) 'INT)
(setq ed (entget e)
ed (subst (cons 44 x) (assoc 44 ed) ed)
ed (subst (cons 70 c) (assoc 70 ed) ed))
(entmod ed)
(entupd e)))
(PDot);************ Main Program ***************************************
(defun bx_ (/ m_v m_n olderr bx_var s bdef ncnt nspc col xsp)
(bx_smd)
(GetOne)
(setq bdef (entget s))
(if (/= "INSERT" (cdr (assoc 0 bdef)))
(err "Not An Insert Entity"))
(bx_get)
(bx_mod s nspc ncnt)
(bx_rmd))
(PDot);************ Main Program ***************************************
(defun by_ (/ m_v m_n olderr by_var s bdef ncnt nspc row ysp)
(bx_smd)
(GetOne)
(setq bdef (entget s))
(if (/= "INSERT" (cdr (assoc 0 bdef)))
(err "Not An Insert Entity"))
(by_get)
(by_mod s nspc ncnt)
(bx_rmd))
(PDot);************ Load Program ***************************************
(defun C:BlkYrow () (by_))
(if by_ (princ "\nBlkYrow Loaded\n"))
(prin1)
(PDot);************ Load Program ***************************************
(defun C:BlkXCol () (bx_))
(if bx_ (princ "\nBlkXCol Loaded\n"))
(prin1)
;================== End Program ========================================
-David
-
David, as I understand it, it is the BLOCK definition ("AcDbBlockBegin") that has a code 71. Or maybe a "AcDbBlockTableRecord"?
Am I right, CAB?
-
David, as I understand it, it is the BLOCK definition ("AcDbBlockBegin") that has a code 71. Or maybe a "AcDbBlockTableRecord"?
Am I right, CAB?
Correctoemundo !!
((-1 . <Entity name: 1bc19e0>)
(0 . "BLOCK")
(330 . <Entity name: 1bc19d8>)
(5 . "2FD4")
(100 . "AcDbEntity")
(67 . 0)
(8 . "0")
(62 . 0)
(6 . "Continuous")
(370 . 0)
(100 . "AcDbBlockBegin")
(70 . 0)
(71 . 1) <-----------------<<< ???????
(10 0.0 0.0 0.0)
(-2 . <Entity name: 1bc19e8>)
(2 . "SHS218")
(1 . "")
)
-
As far as I know, BLOCK table does not contain 71, INSERTs and MINSERTs do.
70 flag in the BLOCK table defines annonymous, attributed, xref, etc. David
-
As far as I know, BLOCK table does not contain 71, INSERTs and MINSERTs do.
70 flag in the BLOCK table defines annonymous, attributed, xref, etc. David
Yes, It is quite a mystery as to how it got there.
I can not get ACAD to accept the code 71 in entmake.
-
Yes, It is quite a mystery as to how it got there.
I can not get ACAD to accept the code 71 in entmake.
Hi...
The code 71 is:
MINSERT row count and also represent to Attributes and Texts, 0 - 2 - 4
-
The code 71 is:
MINSERT row count and also represent to Attributes and Texts, 0 - 2 - 4
That if for INSERT's, we are looking at a BLOCK. There is a difference. :)
-
Many years ago I used minserts briefly for storing intel. I used invisible minserts because they couldn't be seen, couldn't be exploded and would not be removed by purging or the wblocking "*" technique. Excerpt:
(defun MakeIntelBlockDefinition ( Name )
;; empty block definition
(foreach x
(list
(list
'(0 . "BLOCK")
(cons 2 Name)
'(8 . "0")
'(10 0.0 0.0 0.0)
'(70 . 0)
)
'( (0 . "ENDBLK")
(8 . "0")
)
)
(entmake x)
)
)
(defun MakeIntelInsert ( Name )
(if (null (tblsearch "block" Name))
(MakeIntelBlockDefinition Name)
)
(if (null (tblsearch "appid" Name))
(regapp Name)
)
(if
(entmake
(list
'(0 . "INSERT")
'(100 . "AcDbEntity")
'(67 . 0) ;; modelspace
'(60 . 1) ;; invisible
'(8 . "0")
'(100 . "AcDbBlockReference")
(cons 2 Name)
'(10 0.0 0.0 0.0)
'(41 . 1.0)
'(42 . 1.0)
'(43 . 1.0)
'(50 . 0.0)
'(70 . 1) ;; minsert col count
'(71 . 1) ;; minsert row count
'(44 . 0.0) ;; col spacing
'(45 . 0.0) ;; row spacing
'(210 0.0 0.0 1.0)
(list -3 (list Name '(1070 . 0))) ;; xdata init
)
)
(entlast)
)
)
I abandoned the technique after successfully making persistant data by using hard owned xdictionaries.
(my 2¢).
-
I have been experimenting with one of these blocks. When I run FixBlock it eliminates the
code 71 and entmakes a replacement block, but ACAD adds back the code 71. I can only
assume that because the INSERT linked to that block is a minsert that ACAD uses the
code 71 as a flag.
Here is the revised FixBlock routine.
;FixBlock.lsp [June 30, 1998]
;
; Copyright 1996 - 1998 ManuSoft
;
; Freeware from:
; ManuSoft
; http://www.manusoft.com
;
; Load function, then enter FIXBLOCK to redefine selected blocks
; so that all entities are on layer '0', color 'BYBLOCK'.
;
;;===================================================================
;; 09/29/2004 CAB modified to remove the 71 code from block def.
;;===================================================================
(defun C:FixBlock (/ ss cnt idx blkname donelist DXF Update)
(defun DXF (gcode el) (cdr (assoc gcode el)))
(defun Update (bname / ename elist)
(setq ename (tblobjname "BLOCK" bname))
(if
(and ename (zerop (logand 52 (DXF 70 (entget ename '("*"))))))
(progn
(while ename
(setq elist (entget ename '("*"))
elist (subst '(8 . "0") (assoc 8 elist) elist)
elist (if (assoc 62 elist)
(subst '(62 . 0) (assoc 62 elist) elist)
(append elist '((62 . 0)))))
;; CAB added - filter (71 .1) from BLOCK
(if (and (= (cdr(assoc 0 elist)) "BLOCK") (assoc 71 elist))
(setq elist (vl-remove '(71 . 1) elist))
); end CAB add
(entmake elist)
(setq ename (entnext ename)))
(if (= "ENDBLK" (DXF 0 elist)); CAB revised was /=
T ; CAB added, might use this as a 'empty block' counter
;; ELSE return true if created successfully - CAB added
(not(null(entmake '((0 . "ENDBLK") (8 . "0") (62 . 0)))))
;;(entmake '((0 . "ENDBLK") (8 . "0") (62 . 0))) ; CAB removed
)
;;'T CAB removed
); progn
); endif
); defun
;;===================== Start =======================
(if (> (logand (DXF 70 (tblsearch "layer" "0")) 1) 0)
(princ "\nLayer 0 must be thawed before running FIXBLOCK!\n")
(progn
(if
(progn
(princ "\nPress <Enter> to fix ALL defined blocks\n")
(setq cnt 0
ss (ssget '((0 . "INSERT")))))
(progn
(setq idx (sslength ss))
(while (>= (setq idx (1- idx)) 0)
(if (not (member (setq blkname (DXF 2 (entget (ssname ss idx)))) donelist))
(progn
(if (Update blkname) (setq cnt (1+ cnt)))
(setq donelist (cons blkname donelist))))))
(while (setq blkname (DXF 2 (tblnext "BLOCK" (not blkname))))
(if (Update blkname) (setq cnt (1+ cnt)))))
(princ (strcat "\n" (itoa cnt) " block" (if (= cnt 1) "" "s") " redefined\n"))))
(princ)
)
(prompt "\nFix Block Loaded. Enter FixBlock to run.")
(princ)
;End-of-file
-
as I understand it, it is the BLOCK definition ("AcDbBlockBegin") that has a code 71. Or maybe a "AcDbBlockTableRecord"?
That is a strange table definition. How was is extracted? -David
-
If you use the FixBlock routine and stop it here
(setq elist (entget ename '("*"))
You will get this in elist:
((-1 . <Entity name: 1bb15e0>)
(0 . "BLOCK")
(330 . <Entity name: 1bb15d8>)
(5 . "2FD4")
(100 . "AcDbEntity")
(67 . 0)
(8 . "STRUCTURE-11")
(62 . 1)
(6 . "Continuous")
(370 . 0)
(100 . "AcDbBlockBegin")
(70 . 0)
(71 . 1)
(10 0.0 0.0 0.0)
(-2 . <Entity name: 1bb15e8>)
(2 . "SHS218")
(1 . "")
)
-
Have you tried (entmakex) -David
-
I use these to get to the data.
(defun C:ENTITY ( / e d)
(while (setq e (entsel "\nSelect entity: "))
(setq d (entget (car e)))
(foreach n d (princ n) (terpri))
)
(princ)
)
(defun C:OBJECT ( / e o)
(while (setq e (entsel "\nSelect object: "))
(setq o (vlax-ename->vla-object (car e)))
(vlax-dump-object o T)
)
(princ)
)