Author Topic: Entmake after layer creation throws exception!  (Read 7353 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
Re: Entmake after layer creation throws exception!
« Reply #15 on: December 19, 2005, 10:34:59 AM »
ok, Sorry, VLA-AddLine works, I just did'nt change it for all of them.

That is the way it will have to be then.

Also, test this:
Code: [Select]
(Defun C:CrashMe  ()
  (CheckLayerName "Maintained" 8)
  (vla-update zf_Acad-Object)
  (EntMakeX
    (List '(0 . "LINE")
  (cons 8 "Maintained")
;;;   (Cons 8 (CheckLayerName "Maintained" 8))
  '(10 0.0 0.0 0.0)
  '(11 0.0 0.0 0.0)))
  )

Must work, I tested your code and was crashing also on autocad 2005, and even tried with my own functions following the same steps as yours and the same crashing, until I took out the layer definition and by forcing an update to the acad object.
« Last Edit: December 19, 2005, 10:38:04 AM by LE »

zoltan

  • Guest
Re: Entmake after layer creation throws exception!
« Reply #16 on: December 19, 2005, 11:57:47 AM »
Now THAT makes sense!  Thanks LE.  Also should I clear the value of zf_Acad-Object so (ZF_Get-Acad-Object) gets a new instance, or is the pointer the same after the object is updated?

LE

  • Guest
Re: Entmake after layer creation throws exception!
« Reply #17 on: December 19, 2005, 12:10:26 PM »
Now THAT makes sense!  Thanks LE.  Also should I clear the value of zf_Acad-Object so (ZF_Get-Acad-Object) gets a new instance, or is the pointer the same after the object is updated?

I followed your code.... I normally used to simple make a call of:

Code: [Select]
(vlax-get-acad-object)

Anytime I needed and never got any problems.

I also every time I access an activeX automation server via getinterfaceobject or xxx-create-object, I make a call to release and gc...

Have fun.

zoltan

  • Guest
Re: Entmake after layer creation throws exception!
« Reply #18 on: December 19, 2005, 12:42:42 PM »
Don't you find it tedious to get a reference to the Acad-Object, the ActiveDocument, and Modelspace every time you want to creat an entity?  I use the ZF_Get-* functions to save alot of typing.  It caches the object in a variable that it can return instead of getting a new reference every time.  It's faster and I've never had a problem...until now.

Concerning releasing the object after the GetInterfaceObject: that is a good point.  I always made a habit of it when getinng an instance of Excel of other APIs, but I kinda forgot that AutoCAD.AcCmColor.16 is another API.  I guess I should write a subroutine that releases the color object stored in zf_AcadColor and set it to nil, so the next call to (ZF_Get-AcadColor) has to get a new instance every time.

it would look like this:
Code: [Select]

(VLA-Put-TrueColor oEntity (GetColor iColor))
(ReleaseColor)


It might be a good idea to wait on releasing the color untill the end of processing alot of entities, since getting an interface object if kinda slow.  What do you folks think?


good stuff, I learned alot today.

LE

  • Guest
Re: Entmake after layer creation throws exception!
« Reply #19 on: December 19, 2005, 12:53:26 PM »
Don't you find it tedious to get a reference to the Acad-Object, the ActiveDocument, and Modelspace every time you want to creat an entity?  I use the ZF_Get-* functions to save alot of typing.  It caches the object in a variable that it can return instead of getting a new reference every time.  It's faster and I've never had a problem...until now.

I was referring to only make a call to (vlax-get-acad-object) instead of having a global, for the other ones you mentioned is what I normally do.

 :-)