Author Topic: Pulling a selection from a selection ...  (Read 3612 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
Pulling a selection from a selection ...
« on: March 15, 2010, 03:48:17 PM »
Hey guys, I have a bit of a dilemma with a piece of code and a user needs a fix ASAP.
here's my cituation:
Code: [Select]
(setq BlocksInCtab (ssget "_X" (list (cons 0 "INSERT") (cons 410 (getvar 'CTAB)))))
I didn't know when converting a drawing from Microstation to AutoCAD, you could still have some attributed blocks.  Now I need to pull these attributed blocks from the selection set 'BlocksInCtab'.

Here's the information of the blocks I need to take out of the selection set:
Quote
((-1 . <Entity name: 7824bc10>) (0 . "INSERT") (330 . <Entity name: 7e977000>)
(5 . "12") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "INST") (62 . 5)
(6 . "Continuous") (100 . "AcDbBlockReference") (66 . 1) (2 . "INSTAG_2") (10
-14.9502 8.98438 0.0) (41 . 0.00208151) (42 . 0.00208151) (43 . 0.00208151) (50
. 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

Quote
((-1 . <Entity name: 7824bf88>) (0 . "INSERT") (330 . <Entity name: 7e977000>)
(5 . "29") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "TEXT") (62 . 2)
(6 . "Continuous") (100 . "AcDbBlockReference") (66 . 1) (2 . "DETA") (10
-20.8594 16.5518 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71
. 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

Quote
((-1 . <Entity name: 7824bd38>) (0 . "INSERT") (330 . <Entity name: 7e977000>)
(5 . "27") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "TEXT") (62 . 2)
(6 . "Continuous") (100 . "AcDbBlockReference") (66 . 1) (2 . "CTAG") (10
-21.9521 15.8564 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 3.14159) (70 . 0)
(71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

The last two are on the same layer (coincidental), but the first is on a different layer, so selecting by layer is not a good choice.
Can I select them by name with a wildcard for the #'s at the end of the name as with the first one ??
I don't see any information in these which would allow a selection by attribute or a block with text.  Can I select all blocks with text ??
And if that be the case, then this would be a really simple fix if I can select all blocks that do NOT have text.

Code: [Select]
(setq BlocksInCtab (ssget "_X" (list (cons 0 "INSERT") [color=red](cons 0 "ALL BLOCKS WITHOUT TEXT")[/color] (cons 410 (getvar 'CTAB)))))
What are your idea's, suggestions, and otherwise expertise help with this dilemma I have created for myself ??

Thank you in advance.
Hangman  8)

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

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Pulling a selection from a selection ...
« Reply #1 on: March 15, 2010, 03:57:07 PM »
Code: [Select]
(setq BlocksInCtab (ssget "_X" (list (cons 0 "INSERT") (cons 66 1) (cons 410 (getvar 'CTAB)))))
66 = 1  ~ Attributed Blocks

Hangman

  • Swamp Rat
  • Posts: 566
Re: Pulling a selection from a selection ...
« Reply #2 on: March 15, 2010, 04:30:14 PM »
Code: [Select]
(setq BlocksInCtab (ssget "_X" (list (cons 0 "INSERT") (cons 66 1) (cons 410 (getvar 'CTAB)))))
66 = 1  ~ Attributed Blocks

Awesome.  I need to learn my DXF codes.  Unfortunately, the code here selects all blocks that are attributes.  How can I use this to DE-SELECT these attribute blocks from the selection set of all blocks in the drawing ??
Anotherwords, I want to select all blocks in the drawing that are NOT attribute blocks.
So I either need to select all non-attribute blocks, or select all blocks and de-select attribute blocks.
Hangman  8)

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

Hangman

  • Swamp Rat
  • Posts: 566
Re: Pulling a selection from a selection ...
« Reply #3 on: March 15, 2010, 04:36:32 PM »
Wait a second !!!
Ahhhh ...
OK so if I do this, then it'll select all blocks NOT attribute, correct ??
Code: [Select]
(setq BlocksInCtab (ssget "_X" (list (cons 0 "INSERT") [color=red](cons 66 0)[/color] (cons 410 (getvar 'CTAB)))))
Hangman  8)

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

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Pulling a selection from a selection ...
« Reply #4 on: March 15, 2010, 04:49:32 PM »

Hangman

  • Swamp Rat
  • Posts: 566
Re: Pulling a selection from a selection ...
« Reply #5 on: March 15, 2010, 05:05:38 PM »
Reference  And Another

Excellent references, thank you.
Can you explain to me what  <66  -   "Entities follow" flag (fixed)>  means ??
I couldn't find a reference which would describe the scenario ... (... 66 0)  as to choose all blocks except attributes (or somewhere in the likeness of this thought).
Sorry I'm in a hurry to get this fix done.  I will be going back later this evening and research this a LOT further, but right now I need to fix this.

I'm worried if I just throw the  (cons 66 0) in the code and let the user take it, it'll be screwing something else up.  I've tested it on a drawing, and it appears to be selecting those blocks NOT attributed, but if I could just get verification from the masters that this piece will make the selection of all blocks NOT attribute, then I'll be good for the moment.  :)   Thanks.
« Last Edit: March 15, 2010, 05:09:02 PM by Hangman »
Hangman  8)

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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Pulling a selection from a selection ...
« Reply #6 on: March 15, 2010, 05:17:33 PM »
Quote from: Acad Help file on dxf codes for inserts
66
 Variable attributes-follow flag (optional; default = 0); if the value of attributes-follow flag is 1, a series of attribute entities is expected to follow the insert, terminated by a seqend entity
 
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: Pulling a selection from a selection ...
« Reply #7 on: March 15, 2010, 05:39:11 PM »
Quote from: Acad Help file on dxf codes for inserts
66
 Variable attributes-follow flag (optional; default = 0); if the value of attributes-follow flag is 1, a series of attribute entities is expected to follow the insert, terminated by a seqend entity
 

1st, what search did you do for this ??  I tried DXF codes, DXF 66, DXF  to no avail.  See, that's why you guys are the masters !!
2nd, so to my understanding, when 66 is followed by 1, then the attribute blocks are selected, if it's followed by the default zero, then ALL blocks are selected.  I don't think it specifies this very clearly (or perhaps I am just dense enough I don't get it very clearly).
3rd, what does <... terminated by a seqend entity> mean ??  What is seqend ??,  What is a seqend entity ??, and how does it terminate ??
Too many questions, too little time.   I did a quick search for seqend, but haven't found much yet.
You guys just aren't going to give me a quick  YES or NO answer are you ??  :)
Hangman  8)

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

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Pulling a selection from a selection ...
« Reply #8 on: March 15, 2010, 05:51:36 PM »
1st, what search did you do for this ?? 

Look under the DXF reference section, under Entities, then INSERT.



2nd, so to my understanding, when 66 is followed by 1, then the attribute blocks are selected, if it's followed by the default zero, then ALL blocks are selected.  I don't think it specifies this very clearly (or perhaps I am just dense enough I don't get it very clearly).
3rd, what does <... terminated by a seqend entity> mean ??  What is seqend ??,  What is a seqend entity ??, and how does it terminate ??
Too many questions, too little time.   I did a quick search for seqend, but haven't found much yet.
You guys just aren't going to give me a quick  YES or NO answer are you ??  :)

I would instead use:

Code: [Select]
'((0 . "INSERT") (-4 . "<NOT") (66 . 1) (-4 . "NOT>"))

As the DXF 66 code an optional code.

As for the SEQEND entity, it is not such a quick explanation. It is a terminating entity to mark the end of attribute entities (for a block) or vertex entities (for a polyline). Somewhat like the ENDBLK entity in a block definition. This isn't a very good explanantion - hopefully others can embelish.

Lee

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Pulling a selection from a selection ...
« Reply #9 on: March 15, 2010, 06:13:55 PM »
Code: [Select]
(setq ss (ssget '((0 . "INSERT") (-4 . "!=") (66 . 1))))   8-)
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: Pulling a selection from a selection ...
« Reply #10 on: March 15, 2010, 06:36:07 PM »
Well, ...
this is getting in way over my head.  I don't know enough about lists and the dxf codes to follow along with you guys.
at this point I'm just throwing in stuff to see if it works.
I've tried:
Code: [Select]
(setq BlocksInCtab (ssget "_X" (list (cons 0 "INSERT" '((-4 . "<NOT") (66 . 1) (-4 . "NOT>"))) (cons 410 (getvar 'CTAB)))))with too many arguments.
Code: [Select]
(setq BlocksInCtab (ssget "_X" (list (cons '((0 . "INSERT") (-4 . "<NOT") (66 . 1) (-4 . "NOT>"))) (cons 410 (getvar 'CTAB)))))with too few arguments.
I understand that the single quote mark makes everything immediately following NOT evaluated, but I thought I needed to evaluate the (0 . "INSERT") ??  I also need to select the blocks only on the current tab.
I appreciate the code there Alan, but I have no idea what  (-4 . "!=")  would even produce, let alone how to use it.  :)
Hangman  8)

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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Pulling a selection from a selection ...
« Reply #11 on: March 15, 2010, 06:37:47 PM »
2nd, so to my understanding, when 66 is followed by 1, then the attribute blocks are selected, if it's followed by the default zero, then ALL blocks are selected.  I don't think it specifies this very clearly (or perhaps I am just dense enough I don't get it very clearly).

If you add dxf code 66 to your ssget filter list, then:
0 = get blocks without attributes
1 = get blocks with attributes

If you don't add the filter of dxf code of 66, then you will select all blocks, since you are not filtering for dxf code 66.

Does that make sense?
Tim

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

Please think about donating if this post helped you.

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Pulling a selection from a selection ...
« Reply #12 on: March 15, 2010, 06:45:50 PM »
Just to correct your statement:

Code: [Select]
(setq BlocksInCtab (ssget "_X" (list '(0 . "INSERT") '(-4 . "<NOT") '(66 . 1) '(-4 . "NOT>") (cons 410 (getvar 'CTAB)))))

Hangman

  • Swamp Rat
  • Posts: 566
Re: Pulling a selection from a selection ...
« Reply #13 on: March 15, 2010, 06:49:20 PM »

If you add dxf code 66 to your ssget filter list, then:
0 = get blocks without attributes
1 = get blocks with attributes

If you don't add the filter of dxf code of 66, then you will select all blocks, since you are not filtering for dxf code 66.

Does that make sense?

YES !!  That makes much more sense to me.  Thank you Tim.  So my quick test DID work and I CAN get away with the following:
Code: [Select]
(setq BlocksInCtab (ssget "_X" (list (cons 0 "INSERT") (cons 66 0) (cons 410 (getvar 'CTAB)))))Probably not the best way of doing this (from what everyone participating has shown, this is probably one of the worst ways of doing it), but it'll work for now I guess.
Here's my code for this section:
Code: [Select]
(if (setq BlocksInCtab (ssget "_X" (list (cons 0 "INSERT") (cons 66 0) (cons 410 (getvar 'CTAB)))))
    (progn
      (setvar "explmode" 1)
      (mapcar '(lambda(x)(command "._explode" x)) (mapcar 'cadr (ssnamex BlocksInCtab)))
      (setvar "explmode" origexpl)
    )
  )

Thank you again for your help.

Thank you Lee, I understand that a little more, but I've got some serious research to do still.
Hangman  8)

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