如果有一个简单块,其属性为数字,则可以找到所有块,并通过匹配数字12=part52 13=part47在此位置插入一个新块。
一个例子
- ; [color="red"]make a selection set of block name phnum[/color]
- (setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 "phnum"))))
- ; [color="red"] how many blocks[/color]
- (setq len (sslength ss1))
- (setq x 0)
- ; [color="red"]repeat the process for each block[/color]
- (repeat len
- ; [color="red"]et each block 1 at a time and retrieve its attrubutes[/color]
- (foreach att (vlax-invoke [color="red"](vla[/color]x-ename->vla-object (ssname SS1 x )) 'getattributes)
- ; [color="red"]test block tagname is phnum[/color]
- (if (= "PHNUM" (strcase (vla-get-tagstring att)))
- (progn
- ; [color="red"]get the number from the atrribute[/color]
- (setq blknum (vla-get-textstring att))
- ; [color="red"]get the insertion point[/color]
- (setq inspt (vla-get-insertionpoint att))
- )
- )
- )
- ; [color="red"]name of image to be inserted change xxxx to correct directory[/color]
- (setq name (strcat "P:\\xxxxx\" blknum ".jpg" ))
- (princ (strcat "\n" name))
- ; [color="red"]add the raster image name insertion pt scale rotation[/color]
- (vla-AddRaster mspace name inspt 1.5 0.0)
- )
|