Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/22/2022 in all areas

  1. (defun foo (lst) (vl-remove-if '(lambda (x) (or (zerop (car x)) (zerop (cadr x)))) lst) )
    2 points
  2. You may wish to consider this post, which also touches upon the entities constituting nested block references within the block definition.
    1 point
  3. Another version (setq x 10) (setq pt2 (mapcar '+ (vlax-get obj 'insertionpoint ) (list X 0.0 0.0))) (foreach att (vlax-invoke obj 'GetAttributes) (vlax-put att 'insertionpoint pt2) )
    1 point
  4. If some of the attributes would need to be in different locations as opposed to others, what you would need to do is use a dynamic point parameter and then link the attribute in question to the parameter. After that, you can get the dynamic properties using (vlax-invoke obj 'getdynamicblockproperties) and change the value from there. Edit: After further inspection, it's actually possible without. Further to your code above: (foreach x (vlax-invoke obj 'GetAttributes) (setq pt (vlax-get x 'InsertionPoint)) (vla-put-insertionpoint x (vlax-3d-point _your_x_value_ (cadr pt) (caddr pt))) )
    1 point
  5. @SLW210 This is also kinda a re-post https://www.cadtutor.net/forum/topic/76196-search-file-from-autocadhelp/#comment-602247
    1 point
  6. Wrong. AutoLISP does not use the backslash to escape wildcard characters. It is, as ronjonp has stated, the reverse quote. @Emmanuel Delay If you would like to escape all wildcard characters, take a page from Lee Mac's book and have a go using the iterative version of this. All the escape characters in that function is entailed in the list of numbers '(35 64 46 42 63 126 91 93 45 44). The asterisk has the ascii number of 42, therefore if you remove that from the list, that should escape everything except the asterisk, which is what you're after. For any other characters if you're unsure, just invoke (ascii ".") or (ascii ",") or the character you wish in the command line, and remove that number from the list.
    1 point
  7. For primary entities only, use a combination of tblobjname & entnext: (defun blockcomponents ( blk / ent lst ) (if (setq ent (tblobjname "block" blk)) (while (setq ent (entnext ent)) (setq lst (cons ent lst)) ) ) (reverse lst) ) Call the above with a block name argument, e.g.: _$ (blockcomponents "YourBlockName") (<Entity name: 7ffff706950> <Entity name: 7ffff706960> <Entity name: 7ffff706970>) To include nested objects, check for the presence of a block reference (INSERT) entity and include a recursive call, e.g.: (defun blockcomponents ( blk / ent enx lst ) (if (setq ent (tblobjname "block" blk)) (while (setq ent (entnext ent)) (if (= "INSERT" (cdr (assoc 0 (setq enx (entget ent))))) (setq lst (vl-list* (blockcomponents (cdr (assoc 2 enx))) ent lst)) (setq lst (cons ent lst)) ) ) ) (reverse lst) ) The above will return a list of entity names with sublists containing the entity names corresponding to the components of nested block references, e.g.: _$ (blockcomponents "block1") (<Entity name: 7ffff7069f0> <Entity name: 7ffff706a00>) _$ (blockcomponents "block2") (<Entity name: 7ffff706a50> (<Entity name: 7ffff7069f0> <Entity name: 7ffff706a00>) <Entity name: 7ffff706a60> <Entity name: 7ffff706a70>) _$ (blockcomponents "block3") (<Entity name: 7ffff706ad0> (<Entity name: 7ffff706a50> (<Entity name: 7ffff7069f0> <Entity name: 7ffff706a00>) <Entity name: 7ffff706a60> <Entity name: 7ffff706a70>) <Entity name: 7ffff706ae0> <Entity name: 7ffff706af0>) Here, Block1 is nested within Block2 is nested within Block3. If you don't want the nested list structure, use append in place of vl-list*, e.g.: (defun blockcomponents ( blk / ent enx lst ) (if (setq ent (tblobjname "block" blk)) (while (setq ent (entnext ent)) (if (= "INSERT" (cdr (assoc 0 (setq enx (entget ent))))) (setq lst (append (blockcomponents (cdr (assoc 2 enx))) (cons ent lst))) (setq lst (cons ent lst)) ) ) ) (reverse lst) ) This now returns a flat list: _$ (blockcomponents "block1") (<Entity name: 7ffff7069f0> <Entity name: 7ffff706a00>) _$ (blockcomponents "block2") (<Entity name: 7ffff706a50> <Entity name: 7ffff706a00> <Entity name: 7ffff7069f0> <Entity name: 7ffff706a60> <Entity name: 7ffff706a70>) _$ (blockcomponents "block3") (<Entity name: 7ffff706ad0> <Entity name: 7ffff706a70> <Entity name: 7ffff706a60> <Entity name: 7ffff7069f0> <Entity name: 7ffff706a00> <Entity name: 7ffff706a50> <Entity name: 7ffff706ae0> <Entity name: 7ffff706af0>)
    1 point
×
×
  • Create New...