Jump to content

Insert dynamic block with 2 points


Recommended Posts

Posted (edited)

Hi,

I have a dynamic block with a attribute text that tells the distance from a certain (set) point.

this dynamic block has 1 basepoint (the object with a attribute text with distance) and 1 not printing line that i attach to a start point.
This line is dynamic in a way of a polar stretch with 1 grip (the one that i manually have to move to a start point, the other end is at the insertion point of the block).

 

Is it possible by lisp (or other way) to insert that block with the insertionpoint at the 'end' station and the distance line grip at the 'start' point?

i tried to explain it better in the DWG attached to this topic.

 

case.dwg

There is only one 'start' point and multiple end points.

The start and end point are easy to set with a 'getpoint', but the part of manipulating the block to use those point is where i'm stuck.  I don't know how to define the distance line grip and how to move it.

 

Edited by OMEGA-ThundeR
Posted (edited)

Command: ITP,

then the client sets the Endpoint ( = insertpoint of the block "block11")

then the client sets the Startpoint ( = where the green line stretches to)

 

>> The start and end point are easy to set with a 'getpoint', but the part of manipulating the block to use those point is where i'm stuck.  I don't know how to define the distance line grip and how to move it.

Instead of doing this (gripping and stretching the dynamic point) I set the values of the dynamic props.  Just like you can alter the values that you see in the properties pane.

 


(vl-load-com)

;; Set Dynamic Block Property Value  -  Lee Mac
;; Modifies the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; val - [any] New value for property
;; Returns: [any] New value if successful, else nil
(defun LM:setdynpropvalue ( blk prp val )
    (setq prp (strcase prp))
    (vl-some
       '(lambda ( x )
            (if (= prp (strcase (vla-get-propertyname x)))
                (progn
                    (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
                    (cond (val) (t))
                )
            )
        )
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)

;; Set Attribute Value  -  Lee Mac
;; Sets the value of the first attribute with the given tag found within the block, if present.
;; blk - [vla] VLA Block Reference Object
;; tag - [str] Attribute TagString
;; val - [str] Attribute Value
;; Returns: [str] Attribute value if successful, else nil.
(defun LM:vl-setattributevalue ( blk tag val )
    (setq tag (strcase tag))
    (vl-some
       '(lambda ( att )
            (if (= tag (strcase (vla-get-tagstring att)))
                (progn (vla-put-textstring att val) val)
            )
        )
        (vlax-invoke blk 'getattributes)
    )
)


(defun _InsertBlock ( blockname ip / acadObj doc)
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    ;; Insert the block
    (setq insertionPnt (vlax-3d-point ip))
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq blockRefObj (vla-InsertBlock modelSpace insertionPnt blockname 1 1 1 0))
)


;; ITP for Insert block by Two Points
(defun  c:itp ( / blk blkname sp ep dst ang)
 
  (setq blkname "block11")
  (setq ep (getpoint "\nEndpoint: "))
  (setq sp (getpoint "\nStartpoint: "))
 
  ;; calculate the distance and angle
  (setq dst (distance sp ep))
  (setq ang (angle ep sp))
 
  ;; insert block
  (setq blk (_InsertBlock blkname ep))
  ;; set dynamic properties
  (LM:setdynpropvalue blk "Distance" dst)
  (LM:setdynpropvalue blk "Angle1" ang)
 
  ;; set attribute  .  The 3 is for 3 digits after the comma/point.  Feel free to change this.
  (LM:vl-setattributevalue  blk "DISTANCE" (rtos dst 2 3))

)

Edited by Emmanuel Delay

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...