Inserting anonymous blocks in Bcad
I have a routine that creates and inserts anonymous blocks using lisp. I works flawlesly in Acad.
However in BricsCAD the block is created but inserting using entmake does not seem to work...
example:
(entmake (list '(0 . "BLOCK")
(cons 2 "*U")
'(8 . "0")
'(6 . "CONTINUOUS")
'(62 . 256)
(cons 10 (list 10.0 10.0 0.0))
'(70 . 1)
)
)
(entmake (list '(0 . "CIRCLE")
(cons 10 (list 100.0 100.0 0.0))
(cons 40 10.0)
'(210 0.0 0.0 1.0)
)
)
(setq $n (entmake '((0 . "ENDBLK"))))
insert:
(entmake
(list
'(0 . "INSERT")
'(10 . "0")
'(66 . 1)
'(62 . 256)
(cons 2 $n)
(cons 10 (list 0.0 0.0 0.0))
'(41 . 1.0)
'(42 . 1.0)
'(50 . 0.0)
'(43 . 1.0)
'(70 . 0)
'(44 . 0.0)
'(45 . 0.0)
'(210 0.0 0.0 1.0)
)
)
What is wrong ?
However in BricsCAD the block is created but inserting using entmake does not seem to work...
example:
(entmake (list '(0 . "BLOCK")
(cons 2 "*U")
'(8 . "0")
'(6 . "CONTINUOUS")
'(62 . 256)
(cons 10 (list 10.0 10.0 0.0))
'(70 . 1)
)
)
(entmake (list '(0 . "CIRCLE")
(cons 10 (list 100.0 100.0 0.0))
(cons 40 10.0)
'(210 0.0 0.0 1.0)
)
)
(setq $n (entmake '((0 . "ENDBLK"))))
insert:
(entmake
(list
'(0 . "INSERT")
'(10 . "0")
'(66 . 1)
'(62 . 256)
(cons 2 $n)
(cons 10 (list 0.0 0.0 0.0))
'(41 . 1.0)
'(42 . 1.0)
'(50 . 0.0)
'(43 . 1.0)
'(70 . 0)
'(44 . 0.0)
'(45 . 0.0)
'(210 0.0 0.0 1.0)
)
)
What is wrong ?
0
Comments
-
Hi Dirk,
in the INSERT section you have used 10 instead of 8 for the layer name code try
[code];insert:
(entmake
(list
'(0 . "INSERT")
'(8 . "0") ; Layer name
'(66 . 1)
'(62 . 256)
(cons 2 $n)
(cons 10 (list 0.0 0.0 0.0))
'(41 . 1.0)
'(42 . 1.0)
'(50 . 0.0)
'(43 . 1.0)
'(70 . 0)
'(44 . 0.0)
'(45 . 0.0)
'(210 0.0 0.0 1.0)
)
) [/code]
Regards,Jason Bourhill
0 -
you are right, my example is wrong, but when using 8 for layer the problem still exists.
I can make it but inserting still doesn't work.0 -
[code](entmake
(list
'(0 . "INSERT")
'(8 . "0") ; As spotted by Jason
; '(66 . 1) ; There are no attributes
'(62 . 256)
(cons 2 $n)
(cons 10 (list 0.0 0.0 0.0))
'(41 . 1.0)
'(42 . 1.0)
'(50 . 0.0)
'(43 . 1.0)
; '(70 . 0) ; GC 70, 71, 44 and 45 are for Minserts
; '(44 . 0.0)
; '(45 . 0.0)
'(210 0.0 0.0 1.0)
)
)[/code]0 -
DXF-reference for INSERT: http://docs.autodesk.com/ACD/2011/ENU/filesDXF/WS1a9193826455f5ff18cb41610ec0a2e719-7a04.htm
you have various errors in this entmake list:
8 instead of 10 for the layer (was already mentioned)
66 -> look at the dxf-referece what values make sense in your case
70 -> look at the dxf-referece what values make sense in your case
If you declare a GC 70, 44 and 45 then you also need to declare a GC 71
Not necessary, but nicer to read would be to put the GC 43 right after 42.
This code worked for me:
(entmake
(list
'(0 . "INSERT")
'(8 . "0")
'(66 . 0)
'(62 . 256)
(cons 2 $n)
(cons 10 (list 0.0 0.0 0.0))
'(41 . 1.0)
'(42 . 1.0)
'(43 . 1.0)
'(50 . 0.0)
'(70 . 1)
'(71 . 1)
'(44 . 0.0)
'(45 . 0.0)
'(210 0.0 0.0 1.0)
)
)
In this list, however, there are many GCs specified with a value that they would anyways have by default. You could leave them away completely. These are 62, 66, 41, 42, 43, 50, 70, 71, 44, 45, 210. Then your list would look like that:
(entmake
(list
'(0 . "INSERT")
'(8 . "0")
(cons 2 $n)
(cons 10 (list 0.0 0.0 0.0))
)
)0 -
@ Stephan:
Your story is not complete.
Your first (entmake) example will create a Minsert. Your second example creates a Block Reference (both are "INSERT" entities of course).
What is more important:
It can be required to add some of the group codes that you want to leave out. For example if you leave out GC 62 the entity will receive the CECOLOR (and not, what you may want or expect, the 'default' ByLayer color). The same goes for linetype, lineweight etc. It all depends on what you want to achieve.0 -
(entmake (list '(0 . "BLOCK")
(cons 2 "TEST")
'(8 . "0")
'(6 . "CONTINUOUS")
'(62 . 256)
(cons 10 (list 10.0 10.0 0.0))
'(70 . 2)
)
)
(entmake (list '(0 . "CIRCLE")
(cons 10 (list 100.0 100.0 0.0))
(cons 40 10.0)
'(210 0.0 0.0 1.0)
)
)
(entmake
(list
(cons 0 "ATTDEF")
(cons 8 "GEO2CAD_RIOOL_ATTRIB")
(cons 10 (list 10.0 10.0 0.0))
'(40 . 2.5)
(cons 1 "")
'(50 . 0.0)
'(41 . 1.0)
'(51 . 0.0)
(cons 7 "STANDARD")
'(71 . 0)
'(72 . 4)
(cons 10 (list 10.0 10.0 0.0))
'(210 0.0 0.0 1.0)
(cons 3 "MV")
(cons 2 "MV")
'(70 . 1)
'(73 . 0)
'(74 . 0)
)
)
(entmake '((0 . "ENDBLK")))
(entmake
(list
(cons 0 "INSERT")
(cons 8 "0")
(cons 66 1)
(cons 62 256)
(cons 2 "TEST")
(cons 10 (list 0.0 0.0 0.0))
(cons 41 1.0)
(cons 42 1.0)
(cons 50 0.0)
(cons 43 1.0)
(cons 44 0.0)
(cons 45 0.0)
)
)
(entmake
(list
(cons 0 "ATTRIB")
(cons 8 "GEO2CAD_RIOOL_ATTRIB")
(cons 10 (list 10.0 10.0 0.0))
'(40 . 2.5)
(cons 1 "111")
'(50 . 0.0)
'(41 . 1.0)
'(51 . 0.0)
(cons 7 "STANDARD")
'(71 . 0)
'(72 . 4)
(cons 11 (list 10.0 10.0 0.0))
'(210 0.0 0.0 1.0)
(cons 2 "MV")
'(70 . 1)
'(73 . 0)
'(74 . 0)
)
)
(entmake '((0 . "SEQEND")))
I tried with NON anonymous blocks.
Works in ACAD
Does not work in BCAD, the ATTRIB part returns NIL...0 -
maybe the 66 . 1 in the BLOCK definition is not inpterpreted ? 1 stands for ATTRIBS are following.0
-
@ Dirk:
You have received two pieces of advice regarding entmaking an "INSERT". In both you have been advised to do something about the group codes relating to Minsert data. Please look at those again and you will find that your code can work.0 -
I tried also by minimizing group codes, it doesn't help. I also tried using those group codes that are listed within an entget example. What Minsert has to do with this ?
Is anyone able to insert a arbitrary block with attributes using the entmake function. I can't, at least not in BCAD. My function worked fine starting from ACAD r14 over r2000 up to 2012. I can't get it to work in BCAD tho...0 -
I tried using 'normal' blocks with attribs and unnamed blocks with attribs. Defining the block is possible, inserting them using entmake doesn't work, at least not for me.0
-
Hi, Dirk,
as you mentioned, the BLOCK (definition) is created ?
Can you create an INSERT (with or without Attributes) by INSERT command,
using these BLOCK definitions ?
If so, then try omitting the groups codes 44 and 45 ...
Additionally, if you define the BLOCK without attributes (named or anonymous),
does (entmake) then works ?
If nothing helps, please make a little sample and place as SupportRequest ...
the point is, if it works in AutoCAD, then it has to work in Bricscad as well.
Many greetings to all0 -
yes, the block definition is created.
I need this function to insert anonymous blocks, you can't insert anonymous blocks with the insert command, only by using entmake.
Neverteless i tried it with normal blocks (+ attribs) , it can be inserted using INSERT command, so the block definition seems to be correct, i can't insert it however using entmake. Tried omitting group codes (also 44 and 45), nothing helps. I'll make a support request.0 -
Tried omitting group codes (also 44 and 45), nothing helps.
Strange, if I use your code from post #7 but comment out the 44 and 45 group codes, it works without a hitch. Maybe your problem is related to the dwg that you are using for testing?
Changing the code so that it creates an anonymous block also works.
I now understand your confusion regarding Minserts.
Basically every insert has the group codes 70, 71, 44 and 45. But when entmaking an insert an entitylist with these group codes results in a Minsert Block. Of course you then have to supply all 4 group codes. But my guess is that you want a 'normal' insert. In that case you should not have group codes 70, 71, 44 and 45 in the entitylist.
I am attaching a zip.0 -
Thanks very much ! It works now, i didn't change the INSERT entmake because this was succesfull, so i thought the problem was at the ATTRIB entmake because this wasn't succesfull. Removing 70, 44 and 45 at the INSERT entmake is the solution.0
-
BUT i discovered another problem.
I have another type of block where i changed my code also. But this didn't work. This block has a polyline inside the block. I entmake this using VERTICES and also have to end it with SEQEND. I think bcad closes the BLOCK entry on this SEQEND of the polyline because when i remove the POLYLINE part (including the SEQEND) it works perfectly.
Of course i can workaround this easy using lines or a LWPOLYLINE...
0 -
@ Dirk:
I cannot confirm your post #16. I have no problem creating a block with an old style polyline. Bricscad definitely doesn't get mixed up when it encounters the SEQEND entity. Attached: MakeTriangleBlock.lsp0 -
hi,
ok, then it should have been another problem because when changing it into a LWPOLYLINE solves my problem.
thank you !0
This discussion has been closed.