- ;;重生成模型空间中的所有视口
- (defun C:RegenAllViewportsInMspace (/ Doc ActiveViewport Viewports Count_Viewports)
- (setq Doc (vlax-get-property (vlax-get-acad-object) "ActiveDocument");;获取当前文件的名称
- ActiveViewport (vlax-get-property Doc "ActiveViewport");;获取当前使用的视口名称,用于程序结束后切换回当前视口
- Viewports (vlax-get-property Doc "Viewports");;获取所有模型视口的集合名称
- Count_Viewports 0
- )
- ;;逐个重生成模型视口
- (repeat (vlax-get-property Viewports "Count")
- (vlax-put-property Doc "ActiveViewport" (vlax-invoke-method Viewports "Item" Count_Viewports));;激活指定的模型视口
- (vlax-invoke-method Doc "Regen" acActiveViewport);;重生成当前模型视口
- (setq Count_Viewports (1+ Count_Viewports))
- );;repeat (vlax-get-property Viewports "Count")
- (vlax-put-property Doc "ActiveViewport" ActiveViewport);;切换回程序开始时的当前视口
- (princ)
- );;defun C:RegenAllViewportsInMspace
正好看到这个帖子,不知道作者还在吗。这段代码可以逐个给各个视口进行重生成。
如果你不想用重生成,只是要用redraw来重画的话,就把代码里 (vlax-invoke-method Doc "Regen" acActiveViewport) 这句改成 (command "redraw") 就行了。
|