entity select with no click

entity select with no click

Anonymous
Not applicable
1,655 Views
11 Replies
Message 1 of 12

entity select with no click

Anonymous
Not applicable

Hi everybody! I want to select an entity using a name storage in a string. I had the string <Entity name: 45c0c1fe910> already saved as

I want to select an entity using a name storage in a string. I had the string <Entity name: 45c0c1fe910> already saved as attribute in a block. I have many block each ones with differents saved Entity names (this entity names are  polylines). I want to select one block and use the name saved as string to make a copy of his polyline that I had already get the name. (entsel "get the polyline") (entlast )  does not do the job,. Please, HELP!!!!

0 Likes
Accepted solutions (2)
1,656 Views
11 Replies
Replies (11)
Message 2 of 12

Ranjit_Singh
Advisor
Advisor

Looks like you are storing it as a string.

 

Command: (setq a "<Entity name: 7ffff376d20>")
"<Entity name: 7ffff376d20>"
Command: (setq b (car (entsel)))
Select object: <Entity name: 7ffff376d20>
Command: (type (eval b))
ENAME
Command: (type (eval a))
STR

Why do you need entity name stored in a variable?. If you have to, then store the handle and then retrieve the entity name from the handle

 

Command: (setq a (cdr (assoc 5 (entget (car (entsel))))))
Select object: "51E2"
Command: (handent a)
<Entity name: 7ffff376d20>
Message 3 of 12

Anonymous
Not applicable

Thanks, but those suggestions  are not working for me. 

I had some block that I will process with dataextractions and saved in txt. Then I read the txt that have this Entity name of each polylines ralated to the block  created. I want to list my results and put these polylines (copy) in order. I manage to save these Entity name in the block as string, but I can not recall the information, copy or whatever. 

Any help will be appreciated. 

 

 

0 Likes
Message 4 of 12

Ranjit_Singh
Advisor
Advisor

@Anonymous wrote:

Thanks, but those suggestions  are not working for me.....

 


Why are they not working? I mean do you get any error messages? can you describe or share your code. All you have to do is, instead of storing the entity names, store the handles for those entities; and then whenever you wan to retreieve the polyline information just use "Handent to get the entityname and the entity data. Also note that entity names change between drawing sessions and so they will not work after you re-open the drawing. but handles don't changeso you can access the same entitybetween drawing sessions.


@Anonymous wrote:

........  put these polylines (copy) in order. I manage to save these Entity name in the block as string, but I can not recall the information, copy or whatever......


Polylines in order? Can you explain the logic. Once again, storing entity names as string will not work.

0 Likes
Message 5 of 12

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Hi everybody! I want to select an entity using a name storage in a string. ....


An entity name may look like a string of characters, but it is not a string.  Note that the entity-data-list entry for one:

 

(-1 . <Entity name: 7ffffb2f6b0>)

 

does not have double-quotes around it.

 

Can you get the Data Extraction you're using to list the handle instead of the entity name?  You would be able to use that to get the entity;

Kent Cooper, AIA
Message 6 of 12

Anonymous
Not applicable

Thanks four your help, but I am still in the dark. 

 

I had this function that I get it in some place and adapted.

 

(deffun copyobject (obj to / from result)

  (and (eq (type obj) 'ename) (setq obj (vlax-ename->vla-object obj)))

  (cond ((and obj

               (zerop (cdr (assoc 70 (tblsearch "layer" (vla-get-layer obj)))))

               (setq result (vlax-invoke obj 'copy))

            )

           (vlax-invoke-method obj 'GetBoundingBox 'boxmin 'boxmax)

               (setq boxmin (vlax-safearray->list boxmin))

               (setq boxmax (vlax-safearray->list boxmax))

           (vlax-invoke-result 'move boxmin to)

         )

   )

 

,,,,,,

(setq NameHanent (crd (assoc 5 (entget (entlast)))))  100% polylines. 

,,,,,,

 

At one point, I have my block MGS inserted as 

 

(command "_.insert" "MGS" Point factor factor theta NN BB QQ COMP NameHandent), all NUMBERS except NameHandent

 

Then I extracted all blocks, make some mathematics and read a new txt. The last collum in this txt file is NameHandent

 

(fisrt I thing that Entity Name was correct, but I understand now that is not the way to do it) 

 

This line below is working and putting my string without problem in a table at the drawing. 

 

(command "_.text" Linha Altura 0 (vl-princ-to-string NameHandent )

 

like >>   25   12.5 100  12000   COCDE36

 

What is not working, I want to copy this entity in the specific point 

 

(copyobjecto (handent NameHandent ) pt1)  

 

Doesn't work

 

Can I you help me?

 

Thanks guys

 

 

 

 

0 Likes
Message 7 of 12

Ranjit_Singh
Advisor
Advisor

@Anonymous wrote:

Thanks four your help, but I am still in the dark. 

 

....

(copyobjecto (handent NameHandent ) pt1)  

 

.....


I assume copyobjecto is already defined as a function? because your main function is called copyobject and not copyobjecto?

Try the following. you had some global variables and a variant-type error

(defun copyobject  (obj to / from result boxmax boxmin)
 (and (eq (type obj) 'ename) (setq obj (vlax-ename->vla-object obj)))
 (cond ((and obj
             (zerop (cdr (assoc 70 (tblsearch "layer" (vla-get-layer obj)))))
             (setq result (vlax-invoke obj 'copy)))
        (vlax-invoke-method obj 'GetBoundingBox 'boxmin 'boxmax)
        (vlax-invoke-method result 'move boxmin to)))
 (princ))
Message 8 of 12

Anonymous
Not applicable

Not quite yeat

 

Here the error: bad argument type: string COCDE36

 

and stop at the first line of my file. 

 

Thanks four you help. 

0 Likes
Message 9 of 12

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

,,,,,,

(setq NameHanent (crd (assoc 5 (entget (entlast)))))  100% polylines. 

,,,,,,

.... 


First, correct some errors:

 

(setq NameHandent (cdr (assoc 5 (entget (entlast)))));  100% polylines.

 

Then see whether it works.  There may be others -- I happened to notice those.

Kent Cooper, AIA
Message 10 of 12

Anonymous
Not applicable

Thanks,

 

Sorry for the mistakes, This is happening because I am re-writing, working in the computer company and my notebook in with I am right now. But this small erros are really typemistakes. 

The problems seam to be more conceptual. It seems to me that I can not use the name to get the object. This is driving me crazy. How I got the name entity and can not access the entity? Doesn't make sense to me. 

 

Thanks again

 

0 Likes
Message 11 of 12

Ranjit_Singh
Advisor
Advisor
Accepted solution

I still suspect that your handle is coming in as a symbol and not ename. Try checking (type (eval (handent NameHandent))). The code I corrected above works at my end. If it does not work still for you post all your files (dwg lsp etc)

0 Likes
Message 12 of 12

Anonymous
Not applicable
Accepted solution

Finally, I get it. 

 

Thanks for your help. The solutions was to make a new entity (a copy in the same spot) with (entmake ) with all elements from (entget (handent ( ))) and them, do whatever I wanted with this, move (entlast). .....

 

Thanks

 

0 Likes