选择集生成匿名块
- ( defun ssNblock ( ss insertpt / InsPt number blocklist blk index SelectionSetObjs )
- ( vl-load-com )
- (setq AcadObject ( vlax-get-acad-object )
- AcadDocument ( vla-get-ActiveDocument AcadObject )
- ModelSpace ( vla-get-ModelSpace AcadDocument )
- )
- ( setq InsPt ( vlax-3d-point insertpt ) ) ;转化为ActiveX的点
- ( setq number ( sslength ss ) )
- ( setq blocklist ( vla-get-blocks AcadDocument ) )
- ( setq blk ( vla-add blocklist InsPt "*U" ) ) ;定义匿名图块
- ( setq SelectionSetObjs ( vlax-make-safearray vlax-vbobject ( cons 0 ( - number 1 ) ) ) )
- ( defun item ( ss index )
- ( vlax-ename->vla-object ( ssname ss index ) )
- )
- ( setq index 0 )
- ( repeat number
- ( vlax-safearray-put-element SelectionSetObjs index ( item ss index ) )
- ( setq index ( 1+ index ) )
- ) ;把选择集的物体加入到匿名图块
- ( vla-copyobjects AcadDocument SelectionSetObjs blk );采用copyobjects方式
- ( setq ename ( vlax-vla-object->ename blk ) )
- ( princ ( entget ename ) )
- ( vla-insertblock ModelSpace InsPt ( vlax-get-property blk 'name ) 1 1 1 0 );插入图块
- )
|