Author Topic: Still Having Problems with Your Code  (Read 3752 times)

0 Members and 1 Guest are viewing this topic.

sparky

  • Guest
Still Having Problems with Your Code
« on: July 02, 2004, 03:13:42 AM »
:x  :x  :?:  :?:
Code: [Select]
(defun ins-meblock (/ get-mspace ins_pt blk me_block)
  (vl-load-com)

  (defun get-mspace ()
    (vla-get-modelspace
      (vla-get-activedocument
        (vlax-get-acad-object)
        )
      )
    )

    (setq ins_pt (getpoint "\nPlease pick an insertion point: "))
    (if (setq blk_name (getstring T "\nEnter Block name (without ext.): "))
      (if (findfile (strcat blk_name ".dwg"))
        (setq me_block
              (vla-insertblock
                (get-mspace)
                (vlax-3d-point ins_pt)
                blk_name
                1.0
                1.0
                1.0
                0.0
                )
              )
        )
      )
   
  (if me_block
    (if (not (vlax-object-released-p me_block))
      (vlax-release-object me_block)
      )
    )
  (princ)
  )


I've Tried this in my Vlisp editor and it crashes at the "vla-InsertBlock" function.  Block is in the AutoCAD support Path....and findfile returns a strcat path and filename.  Something is seriously wrong here!!!

Please, release me from my pain..Mr. Thomas, Madsen, Se7en, CAB???

hendie

  • Guest
Still Having Problems with Your Code
« Reply #1 on: July 02, 2004, 03:25:37 AM »
how about:
Code: [Select]


(defun ins-meblock (/ get-mspace ins_pt blk me_block)
  (vl-load-com)

  (defun get-mspace ()
    (vla-get-modelspace
      (vla-get-activedocument
        (vlax-get-acad-object)
        )
      )
    )

    (setq ins_pt (getpoint "\nPlease pick an insertion point: "))
    (if (setq blk_name (strcat (getstring T "\nEnter Block name (without ext.): ")".dwg"))
      (if (findfile  blk_name )
      ;(if (findfile (strcat blk_name ".dwg"))
        (setq me_block
              (vla-insertblock
                (get-mspace)
                (vlax-3d-point ins_pt)
                blk_name
                1.0
                1.0
                1.0
                0.0
                )
              )
        )
      )
   
  (if me_block
    (if (not (vlax-object-released-p me_block))
      (vlax-release-object me_block)
      )
    )
  (princ)
  )

sparky

  • Guest
Expand a little...?
« Reply #2 on: July 02, 2004, 04:08:33 AM »
Why does that work?  Is it because all variables are global, in particular the Document and mspace variables?

Or is it something to do with the fact that you didin't stick an extension on the end of the Filename.  And if so why does that matter?

hendie

  • Guest
Still Having Problems with Your Code
« Reply #3 on: July 02, 2004, 04:13:41 AM »
oops sorry, I should have localised them. I just commented them out to see where your code fell down. I've edited the above post to localise them again.

I f you check the help file  you'll see
Quote
Name   String; input-only
The name of the AutoCAD drawing file or the name of the block to insert. If it is a file name, include any path information necessary for AutoCAD to find the file and the .dwg extension.

the way you had structured your routine the vla-insertblock was only being passed the block name and not the extension which it needed

sparky

  • Guest
oops sorry to!!
« Reply #4 on: July 02, 2004, 04:19:12 AM »
You concatenated the Filename with the extension a couple of lines before...so why didn't my code work first off...surely both programs are doing exactly the same thing..they are passing exactly the same string to the InsertBlock method??

OR does the method require you...naahhh...can't be that!

Any furthur suggestions?

SMadsen

  • Guest
Still Having Problems with Your Code
« Reply #5 on: July 02, 2004, 04:24:43 AM »
blk_name is used in vla-insertBlock, which requires a file extension if it's going to insert a block from file. Otherwise, it only looks in the block table.

hendie

  • Guest
Still Having Problems with Your Code
« Reply #6 on: July 02, 2004, 04:26:15 AM »
ah Stig beat me to it (again) while I was editing my post

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Still Having Problems with Your Code
« Reply #7 on: July 02, 2004, 04:30:27 AM »
OOP's now I see where I screwed up. Sorry about that sparky.
TheSwamp.org  (serving the CAD community since 2003)

sparky

  • Guest
Ahh...I give up!!
« Reply #8 on: July 02, 2004, 04:33:20 AM »
I tried all those variations before...I'm sure of it...actually I'm not.

I've looked at it so long, tried so many different things that I can't really remmeber...huh...Stupid or what!

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Still Having Problems with Your Code
« Reply #9 on: July 02, 2004, 04:40:51 AM »
Don't feel bad, if you would have had to correct code to start with it would have helped. I can't believe I missed that............
TheSwamp.org  (serving the CAD community since 2003)