Jump to content

Inserting multiple blocks w/ a coordinates list.


Recommended Posts

Posted

I just tried it with the samppy.txt and it gives an "Command: itree

BAD CHARACTER READ (OCTAL): 0" error message.

 

I also tried it with a text file that has the attribut,coordX,coordY format and it started to do something. But unfortunately, it gave this series of output:

 

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP177A,503749". Press F1 for help.

Unknown command "TP177A,503749". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP1,499874,224193". Press F1 for help.

Unknown command "TP1,499874,224193". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP3,500621,224691". Press F1 for help.

Unknown command "TP3,500621,224691". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP5,502236,225703". Press F1 for help.

Unknown command "TP5,502236,225703". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP7,503405,225746". Press F1 for help.

Unknown command "TP7,503405,225746". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP9,503906,225816". Press F1 for help.

Unknown command "TP9,503906,225816". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP2112,504253". Press F1 for help.

Unknown command "TP2112,504253". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP2171,503678". Press F1 for help.

Unknown command "TP2171,503678". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP2173,503679". Press F1 for help.

Unknown command "TP2173,503679". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP2181,503406". Press F1 for help.

Unknown command "TP2181,503406". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP614,503587". Press F1 for help.

Unknown command "TP614,503587". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

Unknown command "TP11,501746,225941". Press F1 for help.

Unknown command "TP11,501746,225941". Press F1 for help.

 

If anyone spends more time on this, please could you use the following text file?

Green - Trial.txt

  • Replies 92
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    38

  • wannabe

    26

  • wizman

    8

  • ScribbleJ

    8

Posted

it seems ok here, just tested with the attached drawing and sampply.txt.

Posted

Any idea where the problem may be arising? When I try to use it with samppy.txt and the same block I uploaded I still get the "BAD CHARACTER READ (OCTAL): 0" error.

 

Thanks for your time.

Posted

I am currently using one of Lee's previous incarnations which just inserts multiple blocks at the coordinates. Is there any notable routines out there that will allow me to to change the attributes of already inserted blocks using a text file that contains the information to go inside the attribute and the coordinates to verify the correct block is being worked on?

Posted
Unknown command "0". Press F1 for help.

Unknown command "TP614,503587". Press F1 for help.

Unknown command "TP614,503587". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "1". Press F1 for help.

Unknown command "0". Press F1 for help.

 

seems youre already using the new format of sampply.txt, if still not ok, i may have time later.

Posted
seems youre already using the new format of sampply.txt, if still not ok, i may have time later.

 

True. That instance was when I tested out the desirable attribute/coordinate format. The old one(sampy.txt) gives the error listed just above that line of output in that post ("Command: itree

BAD CHARACTER READ (OCTAL): 0" )

 

Cheers.

Posted

Ok, what is the value of your texteval?

Posted

Currently set to 0. I will change it to 1 and try that.

Posted

BAD CHARACTER READ (OCTAL): 0 - still getting this error, even with texteval set to 1

Posted
The last routine gives the error: "NO FUNCTION DEFINITION: BLOCKSEL" as soon as the text file is selected.

 

EDIT: The last routine from Lee.

 

Haha - I had left the ")_ end defun" outside of the [ code] frame! - silly me...

 

Updated now

Posted

OK, this works for me.

 

I have added the alerts to help with the error trapping while we test it.

 

The Co-ordinates need to be listed in one text file and attributes in another

 

Co-ordinates need to be listed like this:

 

5,5

6,6

7,7

 

With commas separating each x,y

 

Hope this helps somewhat for the minute:

 

(defun c:ITREE (/ *error* file afile file1 file2 blk blkfile pts atrib)

   (defun *error* (msg)
   (mapcar 'setvar varlist oldvars)
   (if (= msg "")
       (princ (strcat (itoa blk) " Blocks Inserted."))
       (princ (strcat "\n" (strcase msg)))
   ) ;_  end if
   ) ;_  end defun

   (setq varlist (list "CMDECHO" "ATTREQ")
     oldvars (mapcar 'getvar varlist)
   ) ;_  end setq

   (selcfile)
   (selafile)
   (blocksel)
   
   (setvar "CMDECHO" 0)
   (setvar "ATTREQ" 1)
   (setq file1    (open file "r")
     file2 (open afile "r")
     blk    0
   ) ;_  end setq
   (while
   (and
       (/= (setq pts (read-line file1)) nil) ; READING COORDINATE
       (/= (setq atrib (read-line file2)) nil) ; READING ATTRIBUTE
   ) ;_  end or
   (alert (vl-princ-to-string pts))
   (alert (vl-princ-to-string atrib))
      (command "-insert" blkfile pts "1" "1" "0" atrib atrib
           ) ; PASTING ATTRIBUTE TO COMMAND LINE
      (setq blk (1+ blk))
   ) ;_  end while
   (*error* "")
   (close file1)
   (princ)
) ;_  end defun

(defun selcfile ()
   (setq file (getfiled "Select a Co-ordinate File"
            "C:\\"
            "txt"
            8
          ) ;_  end getfiled
   ) ;_  end setq
) ;_  end defun

(defun selafile ()
   (setq afile (getfiled "Select an Attribute File"
            "C:\\"
            "txt"
            8
          ) ;_  end getfiled
   ) ;_  end setq
) ;_  end defun

(defun blocksel    ()
   (setq
   blkfile    (getfiled "Select a Block"
             "C:\\"
             "dwg"
             8
       ) ;_  end getfiled
   ) ;_  end setq
) ;_  end defun

Posted

Ok, I think I have solved it.

 

This works for me:

 

You can list the coordinate with the corresponding attribute beneath

 

i.e

 

5,5

Hole1

6,6

Hole2

7,7

Hole3

 

 

etc etc

 

(defun c:ITREE (/ *error* file file1 blk blkfile pts atrib)

   (defun *error* (msg)
   (mapcar 'setvar varlist oldvars)
   (if (= msg "")
       (princ (strcat (itoa blk) " Blocks Inserted."))
       (princ (strcat "\n" (strcase msg)))
   ) ;_  end if
   ) ;_  end defun

   (setq varlist (list "CMDECHO" "ATTREQ")
     oldvars (mapcar 'getvar varlist)
   ) ;_  end setq

   (selcfile)
   (blocksel)
   
   (setvar "CMDECHO" 0)
   (setvar "ATTREQ" 1)
   (setq file1    (open file "r")
     blk    0
   ) ;_  end setq
   (while
   (and
       (/= (setq pts (read-line file1)) nil)
       (/= (setq atrib (read-line file1)) nil)
   ) ;_  end or
   (alert (vl-princ-to-string pts))
   (alert (vl-princ-to-string atrib))
      (command "-insert" blkfile pts "1" "1" "0" atrib atrib)
      (setq blk (1+ blk))
   ) ;_  end while
   (*error* "")
   (close file1)
   (princ)
) ;_  end defun

(defun selcfile ()
   (setq file (getfiled "Select a Co-ordinate File"
            "C:\\" ; Change this to change default Search path
            "txt"
            8
          ) ;_  end getfiled
   ) ;_  end setq
) ;_  end defun

(defun blocksel    ()
   (setq
   blkfile    (getfiled "Select a Block"
             "C:\\" ; Change this to change default Search path
             "dwg"
             8
       ) ;_  end getfiled
   ) ;_  end setq
) ;_  end defun

Posted
Ok, I think I have solved it.

 

This works for me:

 

You can list the coordinate with the corresponding attribute beneath

 

i.e

 

5,5

Hole1

6,6

Hole2

7,7

Hole3

 

 

etc etc

 

(defun c:ITREE (/ *error* file file1 blk blkfile pts atrib)

   (defun *error* (msg)
   (mapcar 'setvar varlist oldvars)
   (if (= msg "")
       (princ (strcat (itoa blk) " Blocks Inserted."))
       (princ (strcat "\n" (strcase msg)))
   ) ;_  end if
   ) ;_  end defun

   (setq varlist (list "CMDECHO" "ATTREQ")
     oldvars (mapcar 'getvar varlist)
   ) ;_  end setq

   (selcfile)
   (blocksel)

   (setvar "CMDECHO" 0)
   (setvar "ATTREQ" 1)
   (setq file1    (open file "r")
     blk    0
   ) ;_  end setq
   (while
   (and
       (/= (setq pts (read-line file1)) nil)
       (/= (setq atrib (read-line file1)) nil)
   ) ;_  end or
   (alert (vl-princ-to-string pts))
   (alert (vl-princ-to-string atrib))
      (command "-insert" blkfile pts "1" "1" "0" atrib atrib)
      (setq blk (1+ blk))
   ) ;_  end while
   (*error* "")
   (close file1)
   (princ)
) ;_  end defun

(defun selcfile ()
   (setq file (getfiled "Select a Co-ordinate File"
            "C:\\" ; Change this to change default Search path
            "txt"
            8
          ) ;_  end getfiled
   ) ;_  end setq
) ;_  end defun

(defun blocksel    ()
   (setq
   blkfile    (getfiled "Select a Block"
             "C:\\" ; Change this to change default Search path
             "dwg"
             8
       ) ;_  end getfiled
   ) ;_  end setq
) ;_  end defun

 

Lee, this pops up with a message box showing the coordinates, and then pops up the attribute editor for the block being inserted; it does this for each block.

 

I just pressed ok and left the i.d filed empty, hoping it would automatically populate. Unfortunately it just inserts the blocks with an empty i.d field.

 

Cheers again for your time.

Posted

I added the pop-up so I could see what was being read from the files - these can be removed when the routine works for you. :)

 

Is the attribute being read?

 

I tried the routine with a text file laid out as I have posted in the example and the pop-up displays the correct attrib, and the blocks are displayed with attributes.

Posted
I added the pop-up so I could see what was being read from the files - these can be removed when the routine works for you. :)

 

Is the attribute being read?

 

I tried the routine with a text file laid out as I have posted in the example and the pop-up displays the correct attrib, and the blocks are displayed with attributes.

 

Everything works as you say, except the attributes do not contain the value shown in the message box.

 

I still get prompted to manually enter the text string to be placed into the i.d field, but I just press enter and leave it blank. Is that the correct way?

Posted

The Attribute Editor does not appear for me...

 

Possibly a difference in ACAD versions, or maybe just a different variable setting.

 

 

The way it works for me is that the message box appears, first telling me the coordinate, then another appears telling me the attribute about to be inserted. - then another message box appears with another coordinate, and so on. And after all the message boxes are gone - the block have been inserted and the attributes displayed.

Posted

For the time I will use your previous version and manually enter the i.d.

 

If you ever come across any variable or reasons why I may be getting these issues, please give me a shout.

 

Thanks.

Posted

The Attribute Editor does not appear for me...

 

lee/wannabe

 

if it does appear during an insertion of a block with attribute while running your lisp, set attdia to 0 to remove the editor.....:-)

Posted

Thanks Wizman,

 

Try this Wannabe:

 

(defun c:ITREE (/ *error* file file1 blk blkfile pts atrib blkent)

   (defun *error* (msg)
   (mapcar 'setvar varlist oldvars)
   (if (= msg "")
       (princ (strcat (itoa blk) " Blocks Inserted."))
       (princ (strcat "\n" (strcase msg)))
   ) ;_  end if
   ) ;_  end defun

   (setq varlist (list "CMDECHO" "ATTREQ")
     oldvars (mapcar 'getvar varlist)
   ) ;_  end setq

   (selcfile)
   (blocksel)

   (setvar "CMDECHO" 0)
   (setvar "ATTREQ" 0)
   (setq file1    (open file "r")
     blk    0
   ) ;_  end setq
   (while
   (and
       (/= (setq pts (read-line file1)) nil)
       (/= (setq atrib (read-line file1)) nil)
   ) ;_  end and
      (command "-insert" blkfile pts "1" "1" "0")
      (setq blkent (entget (entnext (entlast))))
      (setq blkent (subst (cons 1 atrib) (assoc 1 blkent) blkent))
      (entmod blkent)
      (setq blk (1+ blk))
   ) ;_  end while
   (command "_regenall")
   (*error* "")
   (close file1)
   (princ)
) ;_  end defun

(defun selcfile    ()
   (setq file (getfiled "Select a Co-ordinate File"
            "C:\\" ; Change this to change default Search path
            "txt"
            8
          ) ;_  end getfiled
   ) ;_  end setq
) ;_  end defun

(defun blocksel    ()
   (setq
   blkfile    (getfiled "Select a Block"
             "C:\\" ; Change this to change default Search path
             "dwg"
             8
       ) ;_  end getfiled
   ) ;_  end setq
) ;_  end defun

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...