See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Getting layer name from block insert

  1. #1
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    261
    Login to Give a bone
    0

    Default Getting layer name from block insert

    Hi All
    I have a routine that I am working on but I am not getting the correct layer information that I need. I want to be able to select a point on the object and if it is a block for the routine to return the layer it was inserted on. I am using the following line of code but it is returning the layer name of the object within the block. Any help is greatly appreciated. Thanks.
    Manuel

    sn_ipt is a selected point on an object that I am passing thru the following code:
    Code:
    (cdr (assoc 8 (entget (car (nentselp sn_ipt)))))
    Last edited by Ed Jobe; 2024-07-15 at 08:30 PM.

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,521
    Login to Give a bone
    0

    Default Re: Getting layer name from block insert

    (nentsel) returns a nested entity. Just use (entsel) for the block reference. A nested entity is a sub-entity of a complex object.
    Last edited by Ed Jobe; 2024-07-15 at 08:28 PM.
    C:> ED WORKING....


    LinkedIn

  3. #3
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    261
    Login to Give a bone
    0

    Default Re: Getting layer name from block insert

    Hi Ed
    Ultimately, I need to be able to select a point on an object (block or otherwise) and extract the layer name. I am not sure how entsel works with a point selection to obtain what I need. Thanks.
    Manuel

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,732
    Login to Give a bone
    0

    Default Re: Getting layer name from block insert

    Quote Originally Posted by cadconcepts View Post
    Hi Ed
    Ultimately, I need to be able to select a point on an object (block or otherwise) and extract the layer name. I am not sure how entsel works with a point selection to obtain what I need. Thanks.
    Manuel
    Utilize ENTSEL, as has aptly been suggested... or consider SSGET.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,521
    Login to Give a bone
    0

    Default Re: Getting layer name from block insert

    Quote Originally Posted by cadconcepts View Post
    Hi Ed
    Ultimately, I need to be able to select a point on an object (block or otherwise) and extract the layer name. I am not sure how entsel works with a point selection to obtain what I need. Thanks.
    Manuel
    All you have to do is remove the 'n', change (nentsel) to (entsel). They work the same way, except that (nentsel) returns the sub entity you clicked on, while (entsel) returns the block.
    C:> ED WORKING....


    LinkedIn

  6. #6
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    261
    Login to Give a bone
    0

    Default Re: Getting layer name from block insert

    Hi Ed
    I tried that and it doesn't work because I am not using nentsel, I am using nentselp. Any other suggestions? Thanks.
    Manuel

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,521
    Login to Give a bone
    0

    Default Re: Getting layer name from block insert

    OK, let's start from the beginning..Maybe you could show some more code.
    If you don't want to change how you are selecting the entity, (how are you getting sn_ipt?), then you could use dxf code 330 to get the handle of the entity's owner.
    C:> ED WORKING....


    LinkedIn

  8. #8
    Member
    Join Date
    2006-11
    Posts
    6
    Login to Give a bone
    2

    Default Re: Getting layer name from block insert

    Bonjour @cadconcepts

    I do not understand why you select a point, it would be better to select an entity and ask the layer with the "assoc 8".
    Example :

    Code:
    (setq blo (car (entsel "\nSelect the block you want to know the insert layer\n")))
    
    (if (= "INSERT" (cdr (assoc 0 (entget blo))))
        (alert
            (strcat "The block "
                    (cdr (assoc 2 (entget blo)))
                    " is on the layer : "
                    (cdr (assoc 8 (entget blo)))
                    )
            )
        (alert "the selected entity is not a block")
        )
    Amicalement
    Last edited by Ed Jobe; 2024-07-17 at 08:57 PM. Reason: Added [CODE] tags, which are available int the Advanced editor.

  9. #9
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,521
    Login to Give a bone
    0

    Default Re: Getting layer name from block insert

    Quote Originally Posted by did-ave View Post
    Bonjour @cadconcepts

    I do not understand why you select a point, it would be better to select an entity and ask the layer with the "assoc 8".
    I assume it's because he wanted to do it programmatically and not prompt the user.
    C:> ED WORKING....


    LinkedIn

  10. #10
    I could stop if I wanted to
    Join Date
    2001-01
    Posts
    261
    Login to Give a bone
    0

    Default Re: Getting layer name from block insert

    Hi Ed
    What I am trying to do is the following. I am inserting an arrow head at the end of a line, polyline or arc and rotating it into place. Once the arrow is insert the routine reads the object at the insertion point and changes the arrow head's layer to match the object. That is working fine with the following code: (cdr (assoc 8 (entget (car (nentselp sn_ipt))))). However, if the object at the insertion point is happens to be a block the previous code returns the nested objects layer not the inserted layer. I hope this clearer. I wish I could post the code but it is part of a much much larger routine. Thanks.
    Manuel

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 3
    Last Post: 2022-03-09, 11:49 PM
  2. Replies: 2
    Last Post: 2018-10-12, 05:19 PM
  3. Replies: 1
    Last Post: 2017-01-15, 12:22 AM
  4. Replies: 0
    Last Post: 2013-10-31, 08:42 PM
  5. Replies: 12
    Last Post: 2010-01-08, 07:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •