Author Topic: Getting from a block ...  (Read 6306 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
Getting from a block ...
« on: October 19, 2006, 05:15:06 PM »
Sorry, but I have another lame question to ask.  My brain is scattered and going in several different directions so my topics tend to go all over the place.

OK, so my question is,
Can I get a circle size from a block ??

I have the head of a 3/4" diameter bolt.  It's a block with an insertion point in the center.
My dream is to get the size of the bolt or circle (either diameter or radius, it doesn't matter) from the block and the insertion point just by doing an entsel or a single selection of the entity.

When I do a list on the object I get the following:
Quote
BLOCK REFERENCE  Layer: "S-Object"
                            Space: Model space
                   Handle = 2c2
       Block Name: "bolteDrawing12"
                at point, X=3'-7 15/16"  Y=    3'-7"  Z=    0'-0"
   X scale factor:   1.00000
   Y scale factor:   1.00000
   rotation angle:      0
   Z scale factor:   1.00000
  Scale uniformly: No
  Allow exploding: Yes

This gives me an insertion point, but not much else.

When I attach it to a variable, I get the following:
Quote
!bolt
(<Entity name: 7ef97150> (44.2741 42.5963 0.0))

**Side question - What are the three numbers listed at the end ??
I tried pulling them out thinking they were the insertion point of the block, but they don't give the same coordinates as the insertion point of the block.

I wouldn't think there is enough info from the !bolt to get the size of the circle, but I don't know enough about extracting info to know any better.

Thank you for your comments & help.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Getting from a block ...
« Reply #1 on: October 19, 2006, 05:24:10 PM »
Is the circle the only circle in the block?

The list of numbers that is returned by (entsel) is the center of the pickbox when the selection was made.

You can access the entity within the block using (nentsel). The radius of the inserted circle will be the block's circle obj's radius times the Insert's scale factor (assuming X/Y/Z scale is equal).

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Getting from a block ...
« Reply #2 on: October 19, 2006, 05:33:10 PM »
As Jeff stated, you can use nentsel something like this:

(setq x (entget (car (nentsel))))

(cdr (assoc 10 x));gets center

(cdr (assoc 40 x));gets radius

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Getting from a block ...
« Reply #3 on: October 19, 2006, 06:00:49 PM »
I would think something would tell you that it was a 3/4" bolt.
Eather the block name, "bolteDrawing12", or the scale?
Although I see it is scaled at 1.0 .
What tells you when inserting the block that it is a 3/4" bolt?

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #4 on: October 19, 2006, 06:14:04 PM »
Thank you for your quick responses.  That's another of the many aspects of the Swamp that is impressive.

Quote
Is the circle the only circle in the block?
Yes it is.  Basically, if you look at a bolt from the top, you will see the outline of the hex head, a pline.  And then the circle, the diameter of the bolt itself.

Doht !!  NENTSEL - of course.  I keep forgetting about that one.

Thank you Ron for that example.  It helps me learn when I see code used in examples.

Quoted from CAB:
Quote
I would think something would tell you that it was a 3/4" bolt.
Eather the block name, "bolteDrawing12", or the scale?
Although I see it is scaled at 1.0 .
What tells you when inserting the block that it is a 3/4" bolt?

We have a routine that asks for an insertion point and a size for the placement of the bolt, then it draws the bolt & makes it a block.
So yes, the scale will show 1.0.  The name of the block, "bolteDrawing12" is the name & count of the blocks in the drawing.  I have been really temped to go modify the routine so it will give you the size in the name but I haven't done it yet.

I'm working on a slotted hole program, but I don't want it part of the bolte program as it is seldom used in comparison.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #5 on: October 20, 2006, 11:56:47 AM »
Aaal-righty then,
I'm having a bit of a struggle here.  Can you guys help me again, please.
This is what I currently have,
Code: [Select]
;
;;;get the bolt
;
  (setq bolt (entget (car (nentsel "\nSelect Bolt...  "))))
;
  (setq pts (caddr bolt))
  (setq pts (cdddr pts))
  (setq pts (car pts))
And this is what is received,
Quote
Select object: ((-1 . <Entity name: 7efe4100>) (0 . "LWPOLYLINE") (330 .
<Entity name: 7efe40e8>) (5 . "2C0") (100 . "AcDbEntity") (67 . 0) (8 . "0")
(100 . "AcDbPolyline") (90 . 6) (70 . 1) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10
-0.375002 0.649523) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 -0.750004 0.0) (40 .
0.0) (41 . 0.0) (42 . 0.0) (10 -0.375002 -0.649523) (40 . 0.0) (41 . 0.0) (42 .
0.0) (10 0.375002 -0.649523) (40 . 0.0) (41 . 0.0) (42 . 0.0) (10 0.750004 0.0)
(40 . 0.0) (41 . 0.0) (42 . 0.0) (10 0.375002 0.649523) (40 . 0.0) (41 . 0.0)
(42 . 0.0) (210 0.0 0.0 1.0))

Ok, so all's good, except the (40 . 0.0) parts.
I'm assuming these are in corrolation with the
Quote
(cdr (assoc 40 x));gets radius
mentioned by Ron.
And that's exactly what I'm receiving,
Quote
Command: (assoc 40 x)
(40 . 0.0)

Command: (cdr (assoc 40 x))
0.0

So it's not pulling the radius of the circle out of my block, right ?.?
What am I to do ??

...  Aaah, I just discovered something.  If I select the 6 sided polygon around the bolt, I get the (0 . "LWPOLYLINE") .
So the circle in the block has to be selected.

Is there a way where I can select the block like so,
Code: [Select]
(setq bolt (nentsel "\nSelect Bolt...  "))
Quote
Command: (setq bolt (nentsel))

Select object: (<Entity name: 7e9320f8> (44.1575 42.7079 0.0) ((1.0 0.0 0.0)
(0.0 1.0 0.0) (0.0 0.0 1.0) (43.9475 43.0145 0.0)) (<Entity name: 7e932110>))

Then pull out what I need, something like,
Code: [Select]
(setq circle (entget (car (ssget "L"))))
To get
Quote
((-1 . <Entity name: 7e9320f8>) (0 . "CIRCLE") (330 . <Entity
name: 7e9320e8>) (5 . "2BF") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 .
"AcDbCircle") (10 0.0 0.0 0.0) (40 . 0.375) (210 0.0 0.0 1.0))

 -- this obviously doesn't work as it is, can you show me how I would do it if it can be done ??
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Getting from a block ...
« Reply #6 on: October 20, 2006, 12:08:46 PM »
What is in the block?  Can you post it?

One way is to step through the blocks definition.  Use 'entsel' to get the block, then use 'entget' to get the list of dxf codes for the block entity.  Then use '(cdr (assoc 2 ' on the 'entget'ed list to get the block name.  Then use 'tblobjname' with ... will be easier to show with code.
Code: [Select]
(setq Sel (entsel "\n Select block: "))
(setq EntData (entget (car Sel)))
(setq BlkName (cdr (assoc 2 EntData)))
(setq BlkDefEnt (tblobjname "block" BlkName))
(setq tempEnt BlkDefEnt)
(while (setq tempEnt (entnext tempEnt))
 (setq tempEntData (entget tempEnt))
 (if (= (cdr (assoc 0 tempEntData)) "CIRCLE")
  (print tempEntData)
  ; here you will grab the stuff you want, I'm just printing it to the command line
 )
)

Hope this explains it more clearly than words.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

uncoolperson

  • Guest
Re: Getting from a block ...
« Reply #7 on: October 20, 2006, 12:13:21 PM »
how is the block put together?

might be able to just reverse the logic to figure out the size.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #8 on: October 20, 2006, 12:35:36 PM »
Sorry, I don't know how to put a pic in here.
I've seen others do it, but, my luck doesn't allow it to happen  :-(

The block is just a 6 sided polygon with a circle in the middle, basically the head of a bolt.
I want the user to make a single selection, either the 6 sided polygon or the circle.  They are mearly selecting the block.
From there, I want the LiSP to distinguish between the polygon & the circle and take the circle.
I then need to get the radius of that circle.
I then can finish the routine.
I think I can get there after I figure this little piece out.  But I know just enough about lisp to get into a lot of trouble.  And my momma said my name was Trouble.   :roll:

Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Getting from a block ...
« Reply #9 on: October 20, 2006, 12:43:46 PM »
Did what I post not help?  To use, at the command line type in '(progn' then past the code, then end the call with ')'.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #10 on: October 20, 2006, 12:52:49 PM »
doht, gett'n there, hang on.

I've got some people bugg'n me about drawings.  Others about details and others about a Friday afternoon deadline.

They won't leave me alone so I can play.  Gimme a few minutes.   ^-^
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CADaver

  • Guest
Re: Getting from a block ...
« Reply #11 on: October 20, 2006, 01:32:04 PM »
We have a routine that asks for an insertion point and a size for the placement of the bolt, then it draws the bolt & makes it a block.
So yes, the scale will show 1.0.  The name of the block, "bolteDrawing12" is the name & count of the blocks in the drawing.  I have been really temped to go modify the routine so it will give you the size in the name but I haven't done it yet.

Okay, I've kind of waded through the posts and I think you'd be MUCH better served focusing your effort here for a couple of reasons. 
One, with a block named to match the size, you won't need twelve different block names for one 3/4" bolt, when you need another just insert the one already built.  That will make counting bolts later a lot easier, plus file size advantages with multiple use blocks..
Two, a simple LIST will tell you size it is
And three, modifying the existing bolt making function should be a lot easier than wading through that particular block to find a circle diameter of a specific circle.

But that's just my take on it.

daron

  • Guest
Re: Getting from a block ...
« Reply #12 on: October 20, 2006, 01:38:08 PM »
Hangman? Another problem with >>what you selected<< is that it is not a circle. It is a
Code: [Select]
(0 . "LWPOLYLINE") polyline. If I remember correctly the 40, 41's are bulge factors or something. For a polyline vertice set, you'd be looking at all the 10's for you coordinates. My guess is you selected the hex, not the circle.

Make sure you select a circle.

daron

  • Guest
Re: Getting from a block ...
« Reply #13 on: October 20, 2006, 01:40:17 PM »
Oops. You caught that. Just ignore me.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #14 on: October 20, 2006, 01:58:36 PM »
Tim,
I've run your routine and it work well.  But when I try to assoc 40 for the circle, I get (40 . 0.0)
So with this info, I'm assuming I'll have to get to 'could-er, caid-er, cadd-er' to get the (40 . 0.375) radius I need ?.?

Quoted from CADaver:
Quote
Okay, I've kind of waded through the posts and I think you'd be MUCH better served focusing your effort here for a couple of reasons.  
One, with a block named to match the size, you won't need twelve different block names for one 3/4" bolt, when you need another just insert the one already built.  That will make counting bolts later a lot easier, plus file size advantages with multiple use blocks..
Two, a simple LIST will tell you size it is
And three, modifying the existing bolt making function should be a lot easier than wading through that particular block to find a circle diameter of a specific circle.
Randy, I agree on renaming the block when it's created and I plan to that eventually.  It would help in a lot of ways, so thank you for you thoughts & comments there.  However, I'd still have to go through a lot of this to get the size of the radius of the circle out of the name to use here.  This way, whatever the name of the block, I will still get the info I need.

I think Tim's on the right track.
The user can pick the block, regardless of what entity of the block is picked.
The routine will decifer the info and find two things;  A- the center of the circle, B- the radius of the circle
The routine will then create points along the X axis from the center of the circle,
And so on and so forth.

Yup Daron, we caught it.  But thanks though, I appreciate your help.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Getting from a block ...
« Reply #15 on: October 20, 2006, 02:58:08 PM »
There can be a problem with a routine based on what I gave you.  If the center point of the circle isn't the same as the insertion point of the block, then you will have to find it.  If the block is scaled, you will have to multiply the scale amount and the radius.  If the block is mirrored, or rotated in a weird way, then getting the correct location of the circle may not be as easy as one would want.

With that said, there is an easy 'fudge' fix.  You can use the ActiveX controls to explode the block, which will make a list of all the objects of the block, and will leave the block as a block within the drawing.  Then you can step through the list, and get the circle object, and all the information, center point and radius, will be correct.  Then you will just delete the objects from the drawing.

Let me know which way you want to go.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #16 on: October 20, 2006, 03:58:21 PM »
Quote
... getting the correct location of the circle may not be as easy as one would want.

Ohh Man !!!   :-o  This is just gett'n worse and worse.  :-D

Ok, so, ...  seriously now, ...  :x
Quote
You can use the ActiveX controls to explode the block, which will make a list of all the objects of the block, and will leave the block as a block within the drawing.  Then you can step through the list, and get the circle object, and all the information, center point and radius, will be correct.  Then you will just delete the objects from the drawing.

Let me know which way you want to go.

Well, I'm a think'n we'll pass the ActiveX controls for the moment.  The insertion point is the center of the circle and the block is made at the end of its' design so it will be (9 times out of 10) a 1 to 1 scale.  The user would have to manually scale the thing which wouldn't make much sense.

Am I correct in my assumption;
Quote
I've run your routine and it worked well.  But when I try to assoc 40 for the circle, I get (40 . 0.0)
So with this info, I'm assuming I'll have to get to 'could-er, caid-er, cadd-er' to get the (40 . 0.375) radius I need ?.?

If not, then we need to keep digging.  If so, then I might have a way through this.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Getting from a block ...
« Reply #17 on: October 20, 2006, 04:09:28 PM »
Okay so if the insertion point is the same as the center of the circle, and the block will not be scaled (I don't like to make assumptions like this), you could do this.  Lunch time for me now.
Code: [Select]
(progn
(setq Sel (entsel "\n Select block: "))
(setq EntData (entget (car Sel)))
(setq BlkName (cdr (assoc 2 EntData)))
(setq BlkDefEnt (tblobjname "block" BlkName))
(setq tempEnt BlkDefEnt)
(while (setq tempEnt (entnext tempEnt))
 (setq tempEntData (entget tempEnt))
 (if (= (cdr (assoc 0 tempEntData)) "CIRCLE")
  (progn
   (prompt (strcat "\n Insertion point of block: " (vl-princ-to-string (cdr (assoc 10 EntData)))))
   (prompt (strcat "\n Circle radius is: " (rtos (cdr (assoc 40 tempEntData)) 2 5)))
  )
 )
)
(princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

uncoolperson

  • Guest
Re: Getting from a block ...
« Reply #18 on: October 20, 2006, 04:13:04 PM »
could i get a copy of the block creation code?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Getting from a block ...
« Reply #19 on: October 20, 2006, 04:17:21 PM »
The center of the circle (assoc 10 EntData) is relative to the insertion point of the block, not the actual WCS point.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #20 on: October 20, 2006, 05:39:57 PM »
Quote
(I don't like to make assumptions like this)
Sorry Tim.  Perhaps I am not understanding what all you are seeking.  I am just the opposite, I try to make all the assumptions I can so my code will catch every scenario possible.


Quote
could i get a copy of the block creation code?
Certainly.
Code: [Select]
...
  (setq bolt_size (getreal (strcat "\nEnter Bolt diameter <" (rtos defbolt_size) ">: ")))
  (or bolt_size (setq bolt_size defbolt_size))
  (setq ipt (getvar "viewctr"))
;
  (setq rad1 (* 0.5 bolt_size))
  (setq pt1 (polar ipt (/ pi 2) (* 0.86603 bolt_size)))
  (setq pt2 (polar ipt (/ pi 2) rad1))
;
  (command ".-layer" "T" "0" "")
  (command ".-layer" "ON" "0" "")
  (setvar "clayer" "0")
;
  (command ".circle" ipt rad1)
  (setq ssel (ssget "l"))
  (command ".polygon" "6" ipt "c" pt1)
  (setq ssel (ssadd (entlast) ssel))
;
  (setq fname (getvar "dwgname"))
  (setq fnamel (strlen fname))
  (setq fname (substr fname 1 (- fnamel 4)))

  (command ".purge" "b" "" "n")
  (setq fn 0)
  (while (/= (tblsearch "block" (strcat "bolte" fname (itoa fn))) nil)
         (setq fn (+ fn 1))
  )
  (setq blnm (strcat "bolte" fname (itoa fn)))
  (command ".block" blnm ipt ssel "")
;
  (if (= (tblsearch "layer" "S-Object") nil)
    (command ".-layer" "n" "S-Object" "c" "3" "S-Object" "")
  )
  (command ".-layer" "T" "S-Object" "")
  (command ".-layer" "ON" "S-Object" "")
  (setvar "clayer" "S-Object")
;
  (setvar "osmode" 182)
  (setq inspt (getpoint (strcat "\nWhere do you want your "(rtos bolt_size)" bolt put?: ")))
  (command ".insert" blnm inspt "" "" "")
...

In fact, Here's most of the code.  This will show you how the bolt is made, how the block is made, and the placement of the block.
All I cut out is the misc. (setvar ... ) and (error ... ) crap.   stuff.

CAB, you are correct, the insertion point of the block is relative to the center of the circle.

Tim, give me a few minutes to look at your code, I've gotta put out another fire.

-- Funny, I don't remember learning the in's and out's of a fireman's job when I was in school learning to draw a straight line.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

uncoolperson

  • Guest
Re: Getting from a block ...
« Reply #21 on: October 20, 2006, 06:10:49 PM »
Code: [Select]
(setq coords (acet-geom-ss-extents (ssadd (car (entsel))) t))
(/ (/ (abs (- (cadr (car coords)) (cadr (cadr coords)))) 0.86603) 2)

should work... it may not be the 'right' way... but it spits out a number that so far looks right

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #22 on: October 20, 2006, 06:49:37 PM »
Tim,
Nicely done.  I now have the radius set to a variable I can use & the insertion point.  Thank you !!

Now, ...  Uuuummmm,  Can you tell me what it's doing ??   :|

I don't understand why I was having such a difficult time with it.
Quote
I've run your routine and it worked well.  But when I try to assoc 40 for the circle, I get (40 . 0.0)
So with this info, I'm assuming I'll have to get to 'could-er, caid-er, cadd-er' to get the (40 . 0.375) radius I need ?.?

I put in the following and had errors:
Code: [Select]
... (if (= (cdr (assoc 0 tempEntData)) "CIRCLE")
          (progn
            (setq inspt (cdr (assoc 10 EntData)));;; I would usually get (10 . 0.0)
            (setq radi (cdr (assoc 40 tempEntData)));;; I would usually get (0.0) if I didn't get an entityp error.
          )
        )
...
 I tried this as well ... (setq radi (assoc 40 tempEntData)) ... ;;; And I would get (40 . 0.0)

I had gone through this several different ways and kept getting errors.  That's why I assumed I'd have to play with the 'car' sequences to extract the radius & insertion point.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #23 on: October 20, 2006, 06:54:27 PM »
hey uncool,

You a ... lost me.  What ummm, ... should I do with this.
Code: [Select]
(setq coords (acet-geom-ss-extents (ssadd (car (entsel))) t))
(/ (/ (abs (- (cadr (car coords)) (cadr (cadr coords)))) 0.86603) 2)

 ???  I don't have a clue   :?  sorry.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Getting from a block ...
« Reply #24 on: October 20, 2006, 07:05:50 PM »
Tim,
Nicely done.  I now have the radius set to a variable I can use & the insertion point.  Thank you !!

Now, ...  Uuuummmm,  Can you tell me what it's doing ??   :|

I don't understand why I was having such a difficult time with it.
Sure.
Code: [Select]
(progn
(setq Sel (entsel "\n Select block: "))
; Selects the entity
(setq EntData (entget (car Sel)))
; Gets the dxf code list of said entity
(setq BlkName (cdr (assoc 2 EntData)))
; Gets the block name for said code list
(setq BlkDefEnt (tblobjname "block" BlkName))
; Gets the entity name of the blocks definition, in the block table
(setq tempEnt BlkDefEnt)
; Sets a temp variable to the blocks entity's name, see why next
(while (setq tempEnt (entnext tempEnt))
; Here we are going to step through the block with 'entnext'
; this will run until there are no more enitities (blocks definition)
 (setq tempEntData (entget tempEnt))
; Gets the dxf code for the entities of the blocks definition
 (if (= (cdr (assoc 0 tempEntData)) "CIRCLE")
; Sees if the entity is a 'circle'
  (progn
   (setq inspt (cdr (assoc 10 EntData)));;; I would usually get (10 . 0.0)
; Since it is a circle, and the block has the same insertion point of the block
; we grab the insertion point of the block 'EntData' NOT the center point of
; the circle, as that would be '(0.0 0.0 0.0)', as it is the origin point of the block
   (setq radi (cdr (assoc 40 tempEntData)));;; I would usually get (0.0) if I didn't get an entityp error.
; Here is where we grab the radius value of the circle 'tempEntData'
  )
 )
)
(princ)
)

Hope that makes it clearer.  When you want to grab the value of the dxf code you must use 'cdr' in association with 'assoc' and the number of the dxf code you want.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

uncoolperson

  • Guest
Re: Getting from a block ...
« Reply #25 on: October 20, 2006, 07:13:15 PM »
all that does is takes the block as a whole uses acet-geom-ss-extents to get the overall height, plugs in some math (that i put together badly)...

it just does the math backwards to get you the number the user entered in when building the block

gets the extents and sets that to coords
Code: [Select]
(setq coords (acet-geom-ss-extents (ssadd (car (entsel))) t))
returns the size (based off math in your building routine, and some bad stuff by me)
Code: [Select]
(/ (/ (abs (- (cadr (car coords)) (cadr (cadr coords)))) 0.86603) 2)
you could also use the coords list to get the center point of the block  with some averaging.

Hangman

  • Swamp Rat
  • Posts: 566
Re: Getting from a block ...
« Reply #26 on: October 20, 2006, 07:23:30 PM »
Ahh, very understandable now uncool, ... Should be Too-Cool, :D
That makes sense & I like the reverse approach your making.  I'm going to keep this in mind (well, in my notes anyway).
Thank you.

And Thanks again Tim.  I really appreciate your help.  And everyone else who has contributed to this string.

I think I've found another area I've been misunderstanding as well.
the line
Code: [Select]
(if (= (cdr (assoc 0 tempEntData)) "CIRCLE")
associates everything.  And IF the tempEntData is not a "CIRCLE", then it loops until it is, right ?.

I know, I'm a little slow.  I like to break things down to a word for word research, I tend to understand it better that way.

Thanks again everyone.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Getting from a block ...
« Reply #27 on: October 20, 2006, 07:34:50 PM »
And Thanks again Tim.  I really appreciate your help.  And everyone else who has contributed to this string.

I think I've found another area I've been misunderstanding as well.
the line
Code: [Select]
(if (= (cdr (assoc 0 tempEntData)) "CIRCLE")
associates everything.  And IF the tempEntData is not a "CIRCLE", then it loops until it is, right ?.

I know, I'm a little slow.  I like to break things down to a word for word research, I tend to understand it better that way.

Thanks again everyone.
You're welcome.  And yes, that is what the 'if' statement is doing.  If it's not a circle, who cares because all we care about (with this code) is a circle.  dxf code 0 = Entity name (type)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.