leonucadomi Posted November 1, 2022 Posted November 1, 2022 hello: (SETQ LEnt (ENTGET (SSNAME (SSGET "x" (list (cons 2 "BLOCK1")) ) 0))) this line extracts the list of an entity called "BLOCK1" but in some drawings that I manage can I have entity called "BLOCK1" or "BLOCK2" I want to use that line to use it with the two names of the entities. maybe using the function "OR" HELP PLEASE Quote
Steven P Posted November 1, 2022 Posted November 1, 2022 This might help, http://lee-mac.com/ssget.html Quote
mhupp Posted November 1, 2022 Posted November 1, 2022 (edited) This is pulling entget data from the first item in the selection set. What I mean is the entity will be random because their is a change for both the blocks to be first. That seem like it might cause more errors depending on what your lisp is doing. This will always be BLOCK1 entget data (setq LEnt (entget (tblobjname "BLOCK" "BLOCK1"))) Edited November 1, 2022 by mhupp 1 Quote
Lee Mac Posted November 1, 2022 Posted November 1, 2022 It depends on what data the OP is looking to obtain from the entity, i.e. whether the data pertains to the block reference or the block definition; the suggestion from @mhupp is obtaining data from the block definition, whereas the code from the OP is obtaining data from the block reference. 1 1 Quote
leonucadomi Posted November 1, 2022 Author Posted November 1, 2022 I use these two types of files... within ABS-457860-001 there's a block reference named BLOCK1 within ABS-457875-001 there's a block reference named BLOCK2 I need the following: 1.- from the name of the file the code is taken 457860-001 (if it has another name it will be another code) and join with "PRE-" in block reference. 2.- from the name of the file the code is taken 457860 (if it has another name it will be another code) and join with "SUB-" in block reference. be either name BLOCK1 or BLOCK2 the result inside the file would be like in the image... ABS-457860-001.dwg ABS-457875-001.dwg Quote
BIGAL Posted November 2, 2022 Posted November 2, 2022 Maybe something like this (defun c:test ( / ss obj blk att1 atts dwgname) (setq ss (ssget "x" '((0 . "INSERT")(cons 2 "Block1,Block2")(410 . "Model")))) (if (= ss nil) (alert "no matching blocks") (progn (setq blk (ssname ss 0)) (setq obj (vlax-ename->vla-object (ssname ss 0))) (setq atts (vlax-invoke obj 'Getattributes)) (setq dwgname (strcat "Pre-" (getvar 'dwgname))) (setq att1 (nth 0 atts)) (vla-put-textstring att1 dwgname) ) ) (princ) ) Quote
ronjonp Posted November 2, 2022 Posted November 2, 2022 56 minutes ago, BIGAL said: Maybe something like this (defun c:test ( / ss obj blk att1 atts dwgname) (setq ss (ssget "x" '((0 . "INSERT")(cons 2 "Block1,Block2")(410 . "Model")))) (if (= ss nil) (alert "no matching blocks") (progn (setq blk (ssname ss 0)) (setq obj (vlax-ename->vla-object (ssname ss 0))) (setq atts (vlax-invoke obj 'Getattributes)) (setq dwgname (strcat "Pre-" (getvar 'dwgname))) (setq att1 (nth 0 atts)) (vla-put-textstring att1 dwgname) ) ) (princ) ) Just a nitpicky thing but you only need to check if 'ss' exists not if it's equal to nothing. Swap the logic. (if ss (progn (setq blk (ssname ss 0)) (setq obj (vlax-ename->vla-object (ssname ss 0))) (setq atts (vlax-invoke obj 'getattributes)) (setq dwgname (strcat "Pre-" (getvar 'dwgname))) (setq att1 (nth 0 atts)) (vla-put-textstring att1 dwgname) ) (alert "no matching blocks") ) and if there are attributes might as well use the '(66 .1) code to the filter. Quote
leonucadomi Posted November 2, 2022 Author Posted November 2, 2022 THANK YOU ALREADY GAVE ME THE SOLUTION Quote
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.