Jump to content

Extract XYZ values from multiple blocks


justindm

Recommended Posts

I'm looking for a way to extract the X, Y and Z values from a set of selected blocks (there may be several types of blocks) and then have it export to a txt file.

 

I'm not sure if it's possible but I'd like to have it export in the order that the blocks were placed.

 

The format I'm looking for would be like this:

x,y,z

x,y,z

and so on...

 

I can do it in Microstation but would prefer an Autcad Lisp.

 

Any help is really appreciated!!!!! :D

Link to comment
Share on other sites

  • Replies 35
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    12

  • alanjt

    6

  • Lee Mac

    5

  • symoin

    5

Top Posters In This Topic

Posted Images

Before you go for lisp, have you tried the Attribute Extraction Tool. This enables the insertion point of blocks to be exported, and I believe it lists the blocks in the order of creation.

 

If that fails then by all means go the lisp route.

Link to comment
Share on other sites

Before you go for lisp, have you tried the Attribute Extraction Tool. This enables the insertion point of blocks to be exported, and I believe it lists the blocks in the order of creation.

 

If that fails then by all means go the lisp route.

Excellent suggestion.

Link to comment
Share on other sites

Check this out ...

 

(defun c:THex (/ fNme ss)
 ; THARWAT 2010
(if (and  (setq fNme (open "D:/Block-coordinates.txt" "w"))
          (setq ss (ssget "_:L" '((0 . "INSERT"))))
        )
   (
    (lambda (i / ss1 e pt1 )
      (while
   (setq ss1
          (ssname ss (setq i (1+ i))))
     (setq e
        (entget ss1))
           (setq pt1
          (cdr (assoc 10 e)))
            
   (write-line
     (strcat  (rtos (car pt1) 2)
             "," (rtos (cadr pt1) 2)
                 ","  (rtos (caddr pt1) 2))
     fNme)
         )
      )
     -1
     )
  (princ)
  )
   (close fNme)
 (princ "\n Written by Tharwat")
 (princ)
 )

 

Good luck. :)

 

Tharwat

Link to comment
Share on other sites

Where do you write your code? Your formatting gives me a headache.

 

I have just finished writting them at the office .

 

And they are simple and you do know that of course , so where did the headache come from ?:)

 

Thanks

 

Tharwat

Link to comment
Share on other sites

I have just finished writting them at the office .

 

And they are simple and you do know that of course , so where did the headache come from ?:)

 

Thanks

 

Tharwat

The formatting.

 

I meant, in what program do you write your code?

Link to comment
Share on other sites

The attached Vlisp editor with Autocad .(vlide)
Look into the Format Selection button. It's your code, I'm just commenting that it's incredibly hard to read.
Link to comment
Share on other sites

Look into the Format Selection button. It's your code, I'm just commenting that it's incredibly hard to read.

Is it due to the unordering way ? I mean, each sentence should be completed in a line to be clear for some people to read them well ?

 

Things like .( for example )

(setq pt (getpoint "\n Specify Point :"))

 

Not like the way I used like ....

 

(setq pt 
(getpoint "\n Specify Point :")
)

 

Is this what you mean ?

Link to comment
Share on other sites

Is it due to the unordering way ? I mean, each sentence should be completed in a line to be clear for some people to read them well ?

 

Things like .( for example )

(setq pt (getpoint "\n Specify Point :"))

 

Not like the way I used like ....

 

(setq pt 
(getpoint "\n Specify Point :")
)

 

Is this what you mean ?

 

No, look at your code. The parens don't match, they don't even make sense. Perhaps it's just a result of you using tabs and forum code brackets don't work well with them.

Link to comment
Share on other sites

No, look at your code. The parens don't match, they don't even make sense. Perhaps it's just a result of you using tabs and forum code brackets don't work well with them.

But in my Vlisp editor they are matched completely . Have you tried the routine ?

 

What about the outcome of it ?

Link to comment
Share on other sites

Make sure the VLIDE isn't inserting tabs into your code:

 

Tools » Environment Options » Visual LISP Formatting Options » (uncheck) Insert Tabs

 

Thanks Lee .

 

That's right , it was checked. so I released it .

 

What is the problem that may cause for the others when they copy and paste codes in their Vlide editors ? Would codes get far from eachothers ?

 

I am still wonder why !

 

Thanks

Link to comment
Share on other sites

@Tharwat - yours works awesome! much simpler than the eattext (and much less filling :lol:)

 

Is there a way to specify the location of the output file? Or just to the same place as the dwg location?

Link to comment
Share on other sites

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...