Author Topic: Is this a 64bits error  (Read 2619 times)

0 Members and 1 Guest are viewing this topic.

jaydee

  • Guest
Is this a 64bits error
« on: September 12, 2011, 11:31:51 PM »
Hi.
I have a feeling this is a 64bits cad/pc error, but not sure.
the code below still manage to remove nest block, but give me the error and failed to regen.
I have read this link
http://www.theswamp.org/index.php?topic=38590.msg437124#msg437124
but couldn't figure out how to incorporate gile (gc:GetObjectIdString) code.
"error: Automation Error. Null object ID"

Thankyou in advace

Code: [Select]
(defun c:ENB ( / NestBlkName)
(setq NestBlkName (strcase (vlax-get-property (vlax-ename->vla-object (cdr (assoc 331 (entget (cdr (assoc 330 (entget (car (nentsel))))))))) 'EffectiveName)))
(remove_blk NestBlkName)
(princ))


(defun remove_blk (bname)
(vl-load-com)
(vlax-for blk (vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(if (= (vla-get-isXref blk) :vlax-false) ;skip xrefs
(vlax-for obj blk
(if (and (vlax-property-available-p obj 'name)
(wcmatch (vla-get-objectname obj) "*Block*")
(eq (strcase (vla-get-name obj)) bname)
)
(vla-delete obj)
)
)
)
)
(vla-regen (vla-get-activedocument (vlax-get-acad-object))
acAllViewports
)
)

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Is this a 64bits error
« Reply #1 on: September 13, 2011, 08:55:44 AM »
Perhaps try something like this:

Code: [Select]
(defun c:enb ( / acblk acdoc obj sel )
    (vl-load-com)
    (setq acdoc (vla-get-activedocument (vlax-get-acad-object))
          acblk (vla-get-blocks acdoc)
    )
    (while
        (progn (setvar 'ERRNO 0) (setq sel (nentsel))
            (cond
                (   (= 7 (getvar 'ERRNO))
                    (princ "\nMissed, Try Again.")
                )
                (   (vl-consp sel)
                    (if
                        (and
                            (= 4 (length sel))
                            (< 1 (length (last sel)))
                        )
                        (progn
                            (setq obj (vlax-ename->vla-object (car (last sel))))
                            (DeleteNestedBlock acblk
                                (strcase
                                    (if (vlax-property-available-p obj 'effectivename)
                                        (vla-get-effectivename obj)
                                        (vla-get-name obj)
                                    )
                                )
                            )
                            (vla-regen acdoc acactiveviewport) t
                        )
                        (princ "\nPlease select a Nested Block.")
                    )
                )
            )
        )
    )
    (princ)
)             

(defun DeleteNestedBlock ( blocks name )
    (vlax-for block blocks
        (if
            (and
                (eq :vlax-false (vla-get-isxref block))
                (eq :vlax-false (vla-get-islayout block))
            )
            (vlax-for obj block
                (if
                    (and
                        (eq "AcDbBlockReference" (vla-get-objectname obj))
                        (or
                            (and
                                (vlax-property-available-p obj 'effectivename)
                                (eq name (strcase (vla-get-effectivename obj)))
                            )
                            (eq name (strcase (vla-get-name obj)))
                        )
                    )
                    (vl-catch-all-apply 'vla-delete (list obj))
                )
            )
        )
    )
)

jaydee

  • Guest
Re: Is this a 64bits error
« Reply #2 on: September 13, 2011, 07:28:58 PM »
Thanks Lee
I just relise the error was due to drawing, not the code. after i audit the drawing and purge, the codes works great.
Thankyou

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Is this a 64bits error
« Reply #3 on: September 13, 2011, 07:35:44 PM »
Well, I hope you and others can learn from my example all the same.  :-)