I am now having problems with creating new layers and then entmaking new
entities on those newly created layers. I get the following error
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
Here is the code
(defun ax:MakeLayer (LayerName color linetype)
;following line inserted for the test only, otherwise set as a standard
global *LayerTable*
(setq LayerTable (vla-get-layers (vla-get-activedocument
(vlax-get-acad-object))))
;
(cond
( (null (tblsearch "layer" LayerName))
(setq LayerName
(vl-catch-all-apply
'vla-add
(list LayerTable Layername)
)
)
(cond
( (vl-catch-all-error-p LayerName)
nil
)
( t
(if color
(vla-put-color LayerName color)
)
(if linetype
(vla-put-linetype LayerName linetype)
)
LayerName
)
)
)
)
)
Here is the test code I use in a new blank drawing (test 50)
(defun test ( i / n color)
;to ensure layers are created each time
(if (setq ss (ssget "x"))
(command "erase" ss "")
)
(command "-purge" "all" "*" "n")
;
(setq n 1)
(repeat i
(setq layername (strcat "layer" (rtos n)))
(setq color (rtos n))
(ax:MakeLayer LayerName color nil)
;
;***see note below
; (command ".-layer" "_c" 1 layername "_c" color layername "")
;
(entmake
(append
'(
(0 . "LINE")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
)
(list(cons 8 layername))
'(
(100 . "AcDbLine")
(10 1506.21 145.703 0.0)
(11 1641.47 263.006 0.0)
(210 0.0 0.0 1.0)
)
)
)
(setq n (1+ n))
)
)
With the line marked *** commented out the program crashes.
With the *** line in the program seems to work?? however the newly created
lines (except for the last one created) are invisible? They list as being
there but once I move the single visible entity out the way none of the
others display. If I use standard lisp to entmake the layer I get the same
(invisible entity) problem.
Although I have called command for testing purposes my completed program is
going to be called by a reactor so I cannot include any command calls.
Any insights to this problem would be greatly appreciated?
(Bobby C. Jones Michael Puckett says to say hello)
Regards
Andrew
Also, how about just (command "._layer" "_c" color layername "")
Also, if you're going to be using this within a reactor, then stick with the AxtiveX approach as (command) will rarely work.
--
John Uhden, Cadlantic/formerly CADvantage
mailto:juh...@cadlantic.com
http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
"Andrew Shalley" <spa...@bogus.com> wrote in message news:48C4495BA1425DA8...@in.WebX.maYIadrTaRb...
Please tell Michael hello for me....are you working with him, or just
seeking his advice like I have so many times in the past...
--
"Make the most of the best
and the least of the worst."
Robert Louis Stevenson
I bet you have stumbled into the "All or nothing" bug. Just for giggles, add
a (command) just before the (entmake). What happens?
--
R. Robert Bell, MCSE
www.AcadX.com
"Andrew Shalley" <spa...@bogus.com> wrote in message
news:48C4495BA1425DA8...@in.WebX.maYIadrTaRb...
;;create a layer
(vla-put-Color (vla-add (vla-get-Layers (vla-get-ActiveDocument
(vlax-get-acad-object))) "TestLayer") 2)
;;create a line
(vla-put-Layer (vla-AddLine (vla-get-ModelSpace (vla-get-ActiveDocument
(vlax-get-Acad-Object)))(vlax-3d-point '(15 15 0)) (vlax-3d-point '(115 15
0))) "TestLayer")
I will try changing my code to use vla* functions for creating the entities
as per Paul's posted code. Will also try and track down the "all or nothing"
post.
Robert: If you check out the *** in my test code you'll see I had tried your
command suggestion, not that I have any clue why it works :)
Does anyone know why the second problem occurs (only the last entity is
visible) when I substitute the ax:makelayer with entmake (this same problem
occurs when adding a command call after the ax:makelayer)?
Bobby: I have had the privilege of working with Michael for about 5 years.
He got me going with this programming stuff and has been some what of a
mentor. As you know he is on a temporary leave of absence, I look forward
to his return.
Regards
Andrew
"Andrew Shalley" <spa...@bogus.com> wrote in message
news:48C4495BA1425DA8...@in.WebX.maYIadrTaRb...
Thanx
"Bobby C. Jones" <bob...@acadx.com> wrote in message
news:BBA159E0BF8A8F6B...@in.WebX.maYIadrTaRb...
What I meant was, use your un-commented-out code, but just add a plain
(command) right before the (entmake). You'll get a *Cancel* at the command
prompt that doesn't mean anything, but that sometimes permits the (entmake)
to work. I'm just curious if it does work then (not that I recommend this as
a final solution!).
entget, entmod, and setvar (!, but I can't remember if getvar is one
also...)
--
R. Robert Bell, MCSE
www.AcadX.com
"Andrew Shalley" <spa...@bogus.com> wrote in message
news:C734773BDD3C8AB9...@in.WebX.maYIadrTaRb...
(defun test ( i / n color)
;to ensure layers are created each time
(if (setq ss (ssget "x"))
(command "erase" ss "")
)
(command "-purge" "all" "*" "n")
;
(setq n 1)
(repeat i
(setq layername (strcat "layer" (rtos n)))
(setq color (rtos n))
(ax:MakeLayer LayerName color nil)
;
(command)
;
(entmake
(append
'(
(0 . "LINE")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
)
(list(cons 8 layername))
'(
(100 . "AcDbLine")
(10 1506.21 145.703 0.0)
(11 1641.47 263.006 0.0)
(210 0.0 0.0 1.0)
)
)
)
(setq n (1+ n))
)
)
This still crashes the drawing
; error: Exception occurred: 0xC0000005 (Access Violation)
; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000005 (Access Violation)
(command ".-layer" "_c" 1 layername "_c" color layername "") in place of
(command) for some reason doesn't crash the drawing? However still all the
entities created are invisible except the last.
Thanks once again, I appreciate your help.
Regards
Andrew
"R. Robert Bell" <rob...@acadx.com> wrote in message
news:A0E916197613F0C0...@in.WebX.maYIadrTaRb...
If you have A2000 then also is a problem when you use the purge command all.
LE.
It is occurring in the purge portion. And thanks for trying the plain
(command), yes you understood!
And as far a visibility goes, it's because you are drawing each line on top
of the other!
(defun test ( i / n color)
;to ensure layers are created each time
(if (setq ss (ssget "x"))
(command "erase" ss "")
)
(command "-purge" "all" "*" "n")
;
(setq n 1)
(repeat i
(setq layername (strcat "layer" (rtos n)))
(setq color (rtos n))
(ax:MakeLayer LayerName color nil)
;
(command)
;
(entmake
(list
'(0 . "LINE")
'(100 . "AcDbEntity")
'(67 . 0)
'(410 . "Model")
(cons 8 layername)
'(100 . "AcDbLine")
(list 10 (+ 1506.21 n) 145.703 0.0)
'(11 1641.47 263.006 0.0)
'(210 0.0 0.0 1.0)
)
)
(setq n (1+ n))
)
)
--
R. Robert Bell, MCSE
www.AcadX.com
"LEsquivel" <arch...@onebox.com> wrote in message
news:8DF1A836DE783674...@in.WebX.maYIadrTaRb...
--
R. Robert Bell, MCSE
www.AcadX.com
"R. Robert Bell" <rob...@acadx.com> wrote in message
news:E346A9D30CEF1284...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
mailto:juh...@cadlantic.com
http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
"Andrew Shalley" <spa...@bogus.com> wrote in message news:6CEF8076488B3D2B...@in.WebX.maYIadrTaRb...
> I know I am drawing one on top of the other but when I move the line on
> screen (picking a single entity) to the side do a regent (a regenall even) I
> only ever see the moved line. When I do a list with a crossing window the
> remaining lines appear and tell me I have 50 lines in total, then when the
> list command exits the 49 lines disappear leaving only the moved one?
>
> Does it work correctly for you?
>
>
> "R. Robert Bell" <rob...@acadx.com> wrote in message
> news:5BC3769AE0F09FD9...@in.WebX.maYIadrTaRb...
Thanks for your input. The test program crashes without the command call to
purge. I only added this line in prior to my post (maybe in doing so I
confused the issue) to ensure that each time someone runs the test function
that the layers are in fact being re-created. If the layers already exist
there is no problem. Maybe as you say there is a problem with the purge
command but this is not the problem I have, sorry for any confusion.
Did you manage to find a way around your purge crash? (I may need to use
this later).
Regards
Andrew
"John Uhden" <juh...@cadlantic.com> wrote in message
news:9B10E69E39B0D76E...@in.WebX.maYIadrTaRb...
> You guys have spent 1/2 my afternoon!
>
> The PURGE *is* the thing. And it's not just the "Purge" command. I used
my own C:PURGEALL routine which employs (vla-delete) and got the same
crashes. I figure it's some violation or failure of AutoCAD's Undo stack or
mechanism. The crash occurs on the entmake, even if buffered by another
(vl-catch-all...).
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> mailto:juh...@cadlantic.com
> http://www.cadlantic.com
> 2 Village Road
> Sea Girt, NJ 08750
> Tel. 732-974-1711
>
>
> "R. Robert Bell" <rob...@acadx.com> wrote in message
news:5BC3769AE0F09FD9...@in.WebX.maYIadrTaRb...
The PURGE *is* the thing. And it's not just the "Purge" command. I used my own C:PURGEALL routine which employs (vla-delete) and got the same crashes. I figure it's some violation or failure of AutoCAD's Undo stack or mechanism. The crash occurs on the entmake, even if buffered by another (vl-catch-all...).
--
John Uhden, Cadlantic/formerly CADvantage
mailto:juh...@cadlantic.com
http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
"R. Robert Bell" <rob...@acadx.com> wrote in message news:5BC3769AE0F09FD9...@in.WebX.maYIadrTaRb...
Does it work correctly for you?
"R. Robert Bell" <rob...@acadx.com> wrote in message
news:5BC3769AE0F09FD9...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
mailto:juh...@cadlantic.com
http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
"Andrew Shalley" <spa...@bogus.com> wrote in message news:40205A09A9CEB4C2...@in.WebX.maYIadrTaRb...
--
R. Robert Bell, MCSE
www.AcadX.com
"Andrew Shalley" <spa...@bogus.com> wrote in message
news:6CEF8076488B3D2B...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
[ mailto:juh...@cadlantic.com ]
[ http://www.cadlantic.com ]
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
"R. Robert Bell" <rob...@acadx.com> wrote in message news:197FA62306E7E3B2...@in.WebX.maYIadrTaRb...
> Yes, and there was no trouble, even with the (command "purge") left in.
>
> --
> R. Robert Bell, MCSE
> www.AcadX.com
>
>
> "John Uhden" <juh...@cadlantic.com> wrote in message
> news:1B3268DC461B3920...@in.WebX.maYIadrTaRb...
If I use plain activex works just fine.
LE.
--
R. Robert Bell, MCSE
www.AcadX.com
"John Uhden" <juh...@cadlantic.com> wrote in message
news:1B3268DC461B3920...@in.WebX.maYIadrTaRb...
I tested more than 30 times here in A2Ki and still no problem or crash, but
in A2000 if I purge all 3 times it crashes.
I do not have TuTu here (or "YouYou" just to translate "TuTu" to English
since the word "Tu" means "You") ;^)
LE
"R. Robert Bell" <rob...@acadx.com> wrote in message
news:3E82218A01FE8FBE...@in.WebX.maYIadrTaRb...
> I crashed it running the 2nd time on TuTu...
>
> --
> R. Robert Bell, MCSE
> www.AcadX.com
>
>
> "LEsquivel" <arch...@onebox.com> wrote in message
> news:2C9435CEE72C217D...@in.WebX.maYIadrTaRb...
> > Actually I did tested Andrew's sample in A2Ki and works fine no problem
at
> > all, except on A2000
> >
> > LEsquivel
> >
> >
>
>
--
R. Robert Bell, MCSE
www.AcadX.com
"LEsquivel" <arch...@onebox.com> wrote in message
news:2C9435CEE72C217D...@in.WebX.maYIadrTaRb...
--
R. Robert Bell, MCSE
www.AcadX.com
"John Uhden" <juh...@cadlantic.com> wrote in message
news:D78BF4ED91E56E4F...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
[ mailto:juh...@cadlantic.com ]
[ http://www.cadlantic.com ]
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
"R. Robert Bell" <rob...@acadx.com> wrote in message news:9CC6DD41AF19C017...@in.WebX.maYIadrTaRb...
--
John Uhden, Cadlantic/formerly CADvantage
[ mailto:juh...@cadlantic.com ]
[ http://www.cadlantic.com ]
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
"R. Robert Bell" <rob...@acadx.com> wrote in message news:3E82218A01FE8FBE...@in.WebX.maYIadrTaRb...
If this is about fatalaties related to entmaking layers and
the issue of a subsequent purge command, I too found this.
The unscientific explanation is that an entmake created
layer that has never been refererenced by at least one
entity seems to have an incomplete entry in the drawing
database. A subsequent purge causes *kaboom* when said
command accesses the layer's incomplete database entry
</guess>.
The cheesy work around I've been using for a couple years
was to entmake a layer by actually entmaking a point entity
with the layer name I wanted, then entdel-eting the newly
created point (all wrapped up in one method). This prevented
the crashes.
If I've missed the mark of your discussion I apologize. Best
of luck friend. Doh, back to class ...
"Andrew Shalley" <spa...@bogus.com> wrote in message
news:40205A09A9CEB4C2...@in.WebX.maYIadrTaRb...
With your modified code all the lines show up (in a pretty fan :-)
Do you know the reason that it doesn't work entmaking one on top of the
other?
"R. Robert Bell" <rob...@acadx.com> wrote in message
news:106BB8A6647B045A...@in.WebX.maYIadrTaRb...
One of the other guys I work with pointed out that as I cycled through test
50 times I was ending up with black lines on top that where masking all the
lines underneath!!!!
Oh the shame.
"Andrew Shalley" <spa...@bogus.com> wrote in message
news:73A97A17034468F1...@in.WebX.maYIadrTaRb...
--
R. Robert Bell, MCSE
www.AcadX.com
"Andrew Shalley" <spa...@bogus.com> wrote in message
news:E493EB031E64A0B9...@in.WebX.maYIadrTaRb...
That pun just loses all it's meaning outside of English... ;-)
Thanks for popping in!
--
R. Robert Bell, MCSE
www.AcadX.com
"michael puckett" <~> wrote in message
news:05991569B85F531D...@in.WebX.maYIadrTaRb...
Back to java servlet bashing ...
"R. Robert Bell" <rob...@acadx.com> wrote in message
news:D9D59931CDBCFF52...@in.WebX.maYIadrTaRb...