Jump to content
haisagiviz

[Solved] ssget: filter by object type

Recommended Posts

haisagiviz

Hi everyone,

 

Please help me how to create 2 selection set (one of "MTEXT" and one of "DIMENSION") from this code I made.

   (setq ss3 (ssget ":L" '((0 . "MTEXT,DIMENSION"))))

 

Thank you so much.

Share this post


Link to post
Share on other sites
Lee Mac
Posted (edited)

Assuming that you only wish to prompt the user once for an initial selection containing both types of object, you would then need to iterate over the selection and separate the entities into two selection sets based on their entity type, for example:

(defun c:test ( / dss ent idx mss )
    (if (setq mss (ssget "_:L" '((0 . "MTEXT,*DIMENSION"))))
        (progn
            (setq dss (ssadd))
            (repeat (setq idx (sslength mss))
                (setq idx (1- idx)
                      ent (ssname mss idx)
                )
                (if (/= (cdr (assoc 0 (entget ent))) "MTEXT")
                    (progn
                        (ssdel ent mss)
                        (ssadd ent dss)
                    )
                )
            )
            (princ
                (strcat
                    "\nSelect contained "
                    (itoa (sslength mss)) " MText and "
                    (itoa (sslength dss)) " Dimensions."
                )
            )
        )
    )
    (princ)
)

 

Edited by Lee Mac
  • Thanks 1

Share this post


Link to post
Share on other sites
haisagiviz

Hi Lee Mac,

Thank you so much. You are always be my idols ^^

 

Sorry but I tested and nil for result. Please help me about that.

 

Command: test
Select objects: Specify opposite corner: 13 found
Select objects:
Error: bad argument type: numberp: nil

 

Best regards,

Share this post


Link to post
Share on other sites
Lee Mac
41 minutes ago, haisagiviz said:

Hi Lee Mac,

Thank you so much. You are always be my idols ^^

 

Sorry but I tested and nil for result. Please help me about that.

 

Command: test
Select objects: Specify opposite corner: 13 found
Select objects:
Error: bad argument type: numberp: nil

 

Best regards,

 

Thank you for your kind words.

 

Are you testing the code exactly as posted?

As I cannot seem to replicate the issue you are encountering and see no reason for this error.

 

Lee

Share this post


Link to post
Share on other sites
haisagiviz

I'm sure I copy exactly as posted because I understood how it work.

But I cannot realize where the error is.

 

P/S: If you have time, could you please help me see the attached DWG file's dimension issue.

It is my big problem for now. I exported DWG from 3D BIM software and the dimension is not correct as AutoCAD system block and have ugly error when modify anything (such as move, change color, layer...)

-> For now I can create a routine with function is filter all dimension I choose and change to other style (have no ugly error) and move all of ref point of dimension to base line (like as No ext line). But one more case I cannot handle is Dimension with Ext line length is custom by BIM software and not be correct understand in AutoCAD.

 

My hope: Can you give me any idea or solution to explode only current Ext line with length of Dimension and without explode the dimension. Like extract Ext line from Dimension.

 

Thank for your time to help everyone and me.

HAI

Screenshot_1.jpg

Dimension Issue.dwg

Share this post


Link to post
Share on other sites
Roy_043
Posted (edited)

I suspect that there is indeed an issue with how @haisagiviz copies code. Maybe this is due to an online translator? Or maybe the code is not saved to a plain text file? In another topic I ended up attaching a Lisp file.

Edited by Roy_043
  • Thanks 1

Share this post


Link to post
Share on other sites
Lee Mac
Posted (edited)

I think you're probably right Roy; I've also noticed that copying code from the forum can occasionally include invisible characters which appear as part of the code (usually at the end), which are then rendered as question marks in the IDE - I think these are caused by the 'Quote selection' link which appears.

 

@haisagiviz Your subsequent question belongs in a separate thread.

Edited by Lee Mac
  • Thanks 1

Share this post


Link to post
Share on other sites
haisagiviz
Posted (edited)

Very thank you Roy and Lee Mac,

 

BTW I will type again from plain text. It is worked for me (Maybe error when copy from browser as Roy said)

I understood how to filter my selection set.

 

Thank you very much.

Edited by haisagiviz

Share this post


Link to post
Share on other sites
Lee Mac

You're welcome @haisagiviz - I'm glad the code is now working for you.

  • Like 1

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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