2017-10-02 6 views
1

AutoCADで1つ以上のスプラインを自動的に「再構築」できるいくつかの機能を探しています。私は30-50のコントロール頂点を持つ数百のスプラインを持つ図面を持っています。これにより、特にこれらのスプラインのグループと直接対話するときに、図面が非常に遅くなります。AutoCADで複数のスプラインを再構築

私は何をしたいのかに関する基本的なコードを持っていますが、この時点でAutoLISPでcvrebuildコマンドを使用する方法はわかりません。コマンドラインでこのコマンドを使用すると、GUIが表示されます。私がこれまで持っていたことは、以下のコードを見てください。

変数n_controlverticesとdegreeを引数として使用して、単にcvrebuildコマンドを呼び出す必要があります。 AutoLISPルーチンは、一度に1つのオブジェクトを通過し、同じパラメータでそれらを再構築します。

コードの外観についてお詫び申し上げます。どうやらAutoLISPのはStackOverflowの

;; Batch rebuild splines 
;;defines command name and variables 

(defunをCとうまく再生されない: "再構築する\ nSelectスプライン" batchrebuild(/ SS N OBJ n_controlvertices度)

;; asks for selection 

(プロンプト )を

;;decides if any splines are selected, and if not selects all 

((ない(setqのSSの(ssgetなら '((0。 "SPLINE"))))) (setqのSSの(ssget "_X"'((0。 "SPLINE")))) )

;;sets allowable entry to [2 (only nonzero) + 4 (only positive)] 

(initget 6)

;;asks for number of fit points. if nothing is entered, it gives it the default value of 20 

(setqののn_controlvertices(GetIntで "\ nNumber制御頂点の< 20>:"))

(IF (= n_controlvertices NIL) (setq n_controlvertices 20) (setq n_controlvertices(fix n_controlvertices))

;;asks for degree of fit points. if nothing is entered, it gives it the default value of 3 

(setqの度合い(GetIntで "\フィット点のnDegree < 3>:"))

( (=度nilの場合) (setqの度3) (setqの度(修正程度) )

(リピート(setqのN(sslength SS))

(setq obj  (vlax-ename->vla-object (ssname ss (setq n (1- n)))) 


    ;;(command cvrebuild) 
    ;;This is the part that I am not sure about 


) 

(のprinc) )

答えて

1

これは方法です。 CVREBUILD(-CVREBUILD)のコマンドラインバージョンを呼び出します。 ユーザ入力設定のシステム変数を扱います。

;; Batch rebuild splines 
;;defines command name and variables 

(defun c:batchrebuild (/ ss n obj n_controlvertices degree rebuild2doption rebuild2ddegree rebuild2dcv cmdecho) 

    ;; asks for selection 
    (prompt "\nSelect splines to be rebuilt.") 

    ;;decides if any splines are selected, and if not selects all 
    (or (setq ss (ssget '((0 . "SPLINE")))) 
     (setq ss (ssget "_X" '((0 . "SPLINE")))) 
) 
    ;; checks if the selection is not empty 
    (if ss 
    (progn 
     ;;sets allowable entry to [2 (only nonzero) + 4 (only positive) 
     (initget 6) 

     ;;asks for number of fit points. if nothing is entered, it gives it the default value of 20 
     (setq n_controlvertices 
      (cond 
       ((getint "\nNumber of control vertices<20>: ")) 
       (T 20) 
      ) 
    ) 

     ;;asks for degree of fit points. if nothing is entered, it gives it the default value of 3 
     (setq degree (cond 
        ((getint "\nDegree of fit points<3>: ")) 
        (T 3) 
        ) 
    ) 

     ;; saves the sysvars current values 
     (setq rebuild2doption (getvar "REBUILD2DOPTION") 
      rebuild2ddegree (getvar "REBUILD2DDEGREE") 
      rebuild2dcv  (getvar "REBUILD2DCV") 
      cmdecho   (getvar "CMDECHO") 
    ) 

     ;; sets the sysvars values according to user inputs 
     (setvar "REBUILD2DOPTION" 1) 
     (setvar "REBUILD2DDEGREE" degree) 
     (setvar "REBUILD2DCV" n_controlvertices) 
     (setvar "CMDECHO" 0) 

     ;; rebuilds the selected splines 
     (repeat (setq n (sslength ss)) 
     (command "_-cvrebuild" (ssname ss (setq n (1- n)))) 
    ) 

     ;; restores sysvars initial values 
     (setvar "REBUILD2DOPTION" rebuild2doption) 
     (setvar "REBUILD2DDEGREE" rebuild2ddegree) 
     (setvar "REBUILD2DCV" rebuild2dcv) 
     (setvar "CMDECHO" cmdecho) 
    ) 
) 
    (princ) 
) 
+0

ありがとうございました!私はAutoLISPの初心者ですが、その中には答えを見つけるのが難しいものがあります。 AutoCADコマンドとそれに関連するパラメータの実装方法に関する資料はありますか?私は、Javaの各コマンドのドキュメント(パラメータ、オプション、インスタンス変数など)を検索できることに慣れています。 –

関連する問題