Jump to content

Recommended Posts

Posted

Chào tất cả các bạn! Mình đến từ Việt Nam.

Sau thời gian tìm hiểu về Lisp những vẫn dốt nên mạo mụi lên đây xin nhờ sự giúp đỡ mọi người.

Hiện tại mình đang viết lisp xuất chiều dài thanh Pline ra Block ATT nhưng không biết cách nào dùng function Field của Lee Mac để link vào chiều dài.

Ví dụ:

Chiều dài tường: 123456m  ====> 123456 mình muốn link field vào. 

Mong được sự giúp đỡ của các bạn!

TT.lsp BLOCK.dwg

Posted

Use google translate

 

Hello all of you! I'm from Vietnam.

After learning about Lisp, she was still ignorant, so she came up here asking for help.

Currently I am writing lisp export length Pline bar to Block ATT but do not know how to use Function Field of Lee Mac to link to the length.

Example:

Wall length: 123456m ====> 123456 I want to link field to. 

Looking forward to your help!

 

Try this 

(defun c:lens (/ ent obj atlength pt atts att obj2)
  (while (setq ent (entsel "\nPick object"))
    (setq obj (vlax-ename->vla-object (car ent)))
    (setq atlength nil)
    (if (vlax-property-available-p obj "Circumference")
      (setq atlength (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-Objectid obj)) ">%).Circumference \\f \"" "%lu2%pr3" "\">%"))
    )
    (if (vlax-property-available-p obj "Length")
      (setq atlength (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-Objectid obj)) ">%).Length \\f \"" "%lu2%pr3" "\">%"))
    )
    (if (= atlength nil)
      (alert "object not supported for length")
      (progn
        (setq pt (getpoint "\nPick insert point"))
        (command "-insert" "Block" pt 1 1 0 "" "")
        (setq obj2 (vlax-ename->vla-object (entlast)))
        (setq atts (vlax-invoke obj2 'getattributes))
        (foreach att atts
          (if (= (vla-get-tagstring att) "L")
            (vla-put-textstring att atlength)
          )
          (command "regen")
        )
      )
    )
  )
  (princ)
)

 

  • Like 1
Posted
27 minutes ago, BIGAL said:

Use google translate

 

Hello all of you! I'm from Vietnam.

After learning about Lisp, she was still ignorant, so she came up here asking for help.

Currently I am writing lisp export length Pline bar to Block ATT but do not know how to use Function Field of Lee Mac to link to the length.

Example:

Wall length: 123456m ====> 123456 I want to link field to. 

Looking forward to your help!

 

Try this 


(defun c:lens (/ ent obj atlength pt atts att obj2)
  (while (setq ent (entsel "\nPick object"))
    (setq obj (vlax-ename->vla-object (car ent)))
    (setq atlength nil)
    (if (vlax-property-available-p obj "Circumference")
      (setq atlength (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-Objectid obj)) ">%).Circumference \\f \"" "%lu2%pr3" "\">%"))
    )
    (if (vlax-property-available-p obj "Length")
      (setq atlength (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-Objectid obj)) ">%).Length \\f \"" "%lu2%pr3" "\">%"))
    )
    (if (= atlength nil)
      (alert "object not supported for length")
      (progn
        (setq pt (getpoint "\nPick insert point"))
        (command "-insert" "Block" pt 1 1 0 "" "")
        (setq obj2 (vlax-ename->vla-object (entlast)))
        (setq atts (vlax-invoke obj2 'getattributes))
        (foreach att atts
          (if (= (vla-get-tagstring att) "L")
            (vla-put-textstring att atlength)
          )
          (command "regen")
        )
      )
    )
  )
  (princ)
)

 

Không được bạn ơi! bạn có thể xem lisp mình gửi lên được không?

  • Dislike 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...