insane Posted December 22, 2014 Share Posted December 22, 2014 (edited) In example i have object named "picket" and i wanna check if there are these pickets then need put in to a list with an entity name. How to do this using vlax-ldata-put. Put these data in to database? All working function would look like this.. I type command (all_data) in command input and the required data savings in autocad memory, and in the console i can check with command vlax-ldata-list (defun c:tinklolinija (/ test pradzios_taskas) (vl-load-com) (while (if (tblsearch "block" "Piketas") (princ "\nBlock Piketas not found.") ) ) (princ) ) Edited December 22, 2014 by insane Quote Link to comment Share on other sites More sharing options...
insane Posted December 22, 2014 Author Share Posted December 22, 2014 So is there anyone help ? how to get entity name? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 23, 2014 Share Posted December 23, 2014 (edited) Look up how to use SSGET and filters you can search for blocks named picket. (setq ss (ssget "X" (list (cons 0 "Insert")(cons 2 "Picket")))) Edited December 24, 2014 by BIGAL Quote Link to comment Share on other sites More sharing options...
insane Posted December 23, 2014 Author Share Posted December 23, 2014 I written code that print counted object names in alertbox but it doesnt show entity name.. What i am missing ? (defun c:bcount ( / p1 b a n obj name) (setq p1 (getstring "\Name of Block : ")) ;get the name of the block (setq b (cons 2 p1)) ;construct a dotted pair - code 2 is for blocks (setq a (ssget "x" (list b))) ;filter for the block name (progn ) (if (/= a nil) ;check if there are any blocks of that name (progn ;if there is… (setq n (sslength a)) (setq ent (entlast a)) ;count the number of blocks (alert (strcat "\nThere are " (itoa n) " in the DataBase. Enity: " (itoa ent) )) ;display the result );progn ;if there are no blocks (alert "\nThere are none in the DataBase") ;inform the user );if (princ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 23, 2014 Share Posted December 23, 2014 What is the need of the entity name to show ? Quote Link to comment Share on other sites More sharing options...
insane Posted December 23, 2014 Author Share Posted December 23, 2014 in this case The name of block but not one all i need, but now its complicated.. Hmm i need another way how to get block names entity. Is there way to check if exact name of block exists ant ten put ta entity name in to database using vlax-ldata-put ? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 24, 2014 Share Posted December 24, 2014 Look at my post and replace "Picket" with p1 Also "\Name should be "\nName the \n means new line. Quote Link to comment Share on other sites More sharing options...
insane Posted December 24, 2014 Author Share Posted December 24, 2014 jap I've noticed differences with existing name showing selection set and some numbers, with p1 returns nil Quote Link to comment Share on other sites More sharing options...
wkplan Posted December 24, 2014 Share Posted December 24, 2014 This sample will show you the entity-name and the vla-object-name of a selected object: (vl-load-com) (setq entity (car (entsel "\nSelect Item: ") ; select item ) ) (if entity ; check if something selected (progn ; if so, do some stuff (princ (strcat "\nEntity is a: " ; combine some strings (vl-princ-to-string (type entity)) ; convert type-output to string ) ) (princ (strcat "\nThe entity name is: " (vl-princ-to-string entity) ) ) ) ) (princ "\nAnd now VLA-data:") (setq a-vla-object (vlax-ename->vla-object entity) ; convert a ename to a vla-object ) (princ (strcat "\nVLA-Entity: " (vl-princ-to-string a-vla-object)) ) Quote Link to comment Share on other sites More sharing options...
insane Posted December 24, 2014 Author Share Posted December 24, 2014 Thats ok i see it get entity name, but for me still need those entity names counting and write in to the database. Without using entsel function i mean automaticaly..when you press function in comman line Quote Link to comment Share on other sites More sharing options...
hmsilva Posted December 24, 2014 Share Posted December 24, 2014 Hi insane, is >> this what you looking for? Henrique Quote Link to comment Share on other sites More sharing options...
wkplan Posted December 24, 2014 Share Posted December 24, 2014 Thats ok i see it get entity name, but for me still need those entity names counting and write in to the database. Without using entsel function i mean automaticaly..when you press function in comman line (defun c:bcount (/ A-VLA-OBJECT CNT ENTITY SS) (vl-load-com) (setq cnt 0) (setq ss (ssget "_X" '((0 . "INSERT")))) (if ss (progn (repeat (sslength ss) (setq entity (ssname ss cnt)) (princ (strcat "\nEntity is a: " ; combine some strings (vl-princ-to-string (type entity)) ; convert type-output to string ) ) (princ (strcat "\nThe entity name is: " (vl-princ-to-string entity) ) ) (princ "\nAnd now VLA-data:") (setq a-vla-object (vlax-ename->vla-object entity) ; convert a ename to a vla-object ) (princ (strcat "\nVLA-Entity: " (vl-princ-to-string a-vla-object)) ) (setq cnt (1+ cnt)) ) (princ (strcat "\nBlocks found: " (itoa cnt))) (princ) ) ) ) (c:bcount) You may find this usefull: http://www.theswamp.org/index.php?topic=43710.0 Quote Link to comment Share on other sites More sharing options...
insane Posted December 25, 2014 Author Share Posted December 25, 2014 well this code a lot warmer, if its possible to choose what name of entity would save ? Quote Link to comment Share on other sites More sharing options...
wkplan Posted December 26, 2014 Share Posted December 26, 2014 well this code a lot warmer, if its possible to choose what name of entity would save ? Not sure what you mean, do you want only blocks with a specific name? Change: (setq ss (ssget "_X" '((0 . "INSERT")))) To: (setq ss (ssget "_X" (list '(0 . "INSERT") [color=blue]'(2 . "YOUR_BLOCKNAME")[/color]))) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.