AutoCAD VBA對齊物件

2021-09-06 02:43:59 字數 1825 閱讀 5702

autocad vba對齊物件,**如下。

sub alignent()

dim ss as acadselectionset

set ss = createselectionset

ss.selectonscreen

dim ent as acadentity

dim minpoint as variant

dim maxpoint as variant

if ss.count > 0 then

dim alignmode as string

on error resume next

thisdrawing.utility.initializeuserinput 0, "left middle right"

alignmode = thisdrawing.utility.getkeyword("選擇對齊方式[左對齊(l)/對中(m)/右對齊(r)]《左對齊》:")

if err then alignmode = "left"

if alignmode = "" then alignmode = "left"

dim alignpoint as variant

dim movepoint(2) as double

alignpoint = thisdrawing.utility.getpoint(, "請選擇對起點:")

for each ent in ss

ent.getboundingbox minpoint, maxpoint

select case alignmode

case "left"

movepoint(0) = minpoint(0)

movepoint(1) = alignpoint(2)

movepoint(2) = minpoint(2)

case "middle"

movepoint(0) = (minpoint(0) + maxpoint(0)) / 2

movepoint(1) = alignpoint(1)

movepoint(2) = minpoint(2)

case "right"

movepoint(0) = maxpoint(0)

movepoint(1) = alignpoint(1)

movepoint(2) = maxpoint(2)

end select

ent.move movepoint, alignpoint

update

next

else

thisdrawing.utility.prompt vbcr & "未選定物件,自動退出……"

end if

end sub

public function createselectionset(optional ssname as string = "ss") as acadselectionset

dim ss as acadselectionset

on error resume next

set ss = thisdrawing.selectionsets(ssname)

if err then set ss = thisdrawing.selectionsets.add(ssname)

ss.clear

set creatselectionset = ss

end function

**完。

執行時提示「物件變數或with塊變數未設定」。

AutoCAD VBA開啟檔案對話方塊

利用vlax的com物件函式 var fileopendlg 開啟檔案 d xls title 字串,指定對話方塊的標籤。default 要使用的預設檔名 可為空字串 ext 預設的副檔名。如果 ext 為空字串 則預設值為 所有檔案型別 如果該引數中包含 dwg 檔案型別,則 getfiled 函...

Boolan c 物件模型 記憶體對齊 總結

前言 c language博大精深,需要我們透過現象看清本質才是正道。不積矽步,無以至千里 不積小流,無以成江海。堅持總結,堅持寫作。下面是對第四周的作業的總結。1.物件模型圖 圖1 物件模型圖 2.記憶體對齊 圖2 fruit 3.一些相關知識點總結 1 資料型別所佔位元組 long int 在w...

將選定的文字物件左對齊 右對齊或對中

程式名稱 物件水平對齊程式 執行命令 txtal 程式功能 將選定的物件左對齊 右對齊或對中。defun c txtal selobjs oldcmdecho 定義命令txtal,區域性變數selobjs,oldcmdecho setq oldcmdecho getvar cmdecho oldcm...