Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Making a Dynamic Block Grip "hot"

11 REPLIES 11
Reply
Message 1 of 12
Redraiderr2009
1691 Views, 11 Replies

Making a Dynamic Block Grip "hot"

Basically I want a dynamic block that works like an MLeader. I have built the block and can manipulate parameters, but haven't found a way to select a specific dynamic block grip.

It has a base point but then after placing the block I want to activate the stretch grip. Has anyone ever tried this?

 

11 REPLIES 11
Message 2 of 12
bhull1985
in reply to: Redraiderr2009

That's an interesting task you've taken on-

I would like to know the answers too!

And I'll help in getting them if they're still unanswered.

My first inclination is to say that yes it's possible, I even remember reading some forum posts that were mentioning how to make a certain visibility state active and current within a dynamic block reference. I know this is different than activating a grip for stretching but they're both parameters of a dynamic block reference within autocad- see, hardly different!

 

Anyways, I'll look around theswamp and try to find what I've seen previously, or anything else relevant to accomplishing this task, because I've been wanting to use lisp to mess with these for a while now.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 3 of 12
Redraiderr2009
in reply to: bhull1985

Thanks,

I am trying to develop a new note system for us. I was looking at MLeaders and Dynamic Blocks. I find MLeaders a little clunky and hard to program for because of having to use the DXF codes to manage them. I am really familiar with dynamic blocks, but making them act like an MLeader is a little challenging.

 

I found this from LeeMac.

http://www.theswamp.org/index.php?topic=43789.0

 

Its close, but not quite there.

Message 4 of 12


@Redraiderr2009 wrote:

Basically I want a dynamic block that works like an MLeader. I have built the block and can manipulate parameters, but haven't found a way to select a specific dynamic block grip.

It has a base point but then after placing the block I want to activate the stretch grip. Has anyone ever tried this?

 


Try this one.

Not sure whether you looking for this (File attached.)

See the image in here.

Spoiler
Mleader.JPG
Message 5 of 12
bhull1985
in reply to: Ajilal.Vijayan

Try this one:

attached to keep formatting.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 6 of 12

 That is what I want, but now I want to make piont2 hot after inserting the block, to mimic the mleader flow of events when inserted.

Message 7 of 12
Redraiderr2009
in reply to: bhull1985

That does give me all the dynamic block properties, but not really making them hot. I still think that rubberband for "getpoint", I found at the swamp is the closest thing that I am looking for so far. 

Message 8 of 12

You think there is any way to chain the properties so that if the angle of point 2 and the arrow is > than 270 and < 90 degrees it will automatically flip the block?

Message 9 of 12
bhull1985
in reply to: Redraiderr2009

Yeah you could write a conditional to check the angle and if it's within that range you could have it preform a mirror command on the entity.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 10 of 12
Ajilal.Vijayan
in reply to: bhull1985

I modified the code from swamp and used codes from Lee Mac and Alan JT.

 

Please find the code in here.

Spoiler
(defun c:test ( / apn dpn dsp ins obj prn )

;from 
;http://forums.augi.com/showthread.php?101772-Add-blocks-to-drawing-without-INSERT-command&p=980191&v...
;; Insert block into drawing
;;; #Name - name of block
;;; #InsPt - insert point
;;; #XScale - block X scale
;;; #YScale - block Y scale
;;; #Rot - block rotation
;;; Alan J. Thompson, 04.21.09
(defun AT:InsertBlock (#Name #InsPt #XScale #YScale #Rot)

  (if (or (tblsearch "block" #Name)
          (findfile #Name)
      ) ;_ or
    (vla-insertblock
      ((if (eq (getvar "cvport") 1)
         vla-get-paperspace
         vla-get-modelspace
       ) ;_ if
        (vla-get-ActiveDocument
          (vlax-get-acad-object)
        ) ;_ vla-get-ActiveDocument
      )
      (vlax-3d-point #InsPt)
      #Name
      #XScale
      #YScale
      #XScale
      #Rot
    ) ;_ vla-insert-block
  ) ;_ if
) ;_ defun


;from
;http://www.lee-mac.com/dynamicblockfunctions.html#toggleflipstate
(defun LM:toggleflipstate ( blk )
    (vl-some
       '(lambda ( prp / rtn )
            (if (equal '(0 1) (vlax-get prp 'allowedvalues))
                (progn
                    (vla-put-value prp (vlax-make-variant (setq rtn (- 1 (vlax-get prp 'value))) vlax-vbinteger))
                    rtn
                )
            )
        )
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)

;from
;http://www.theswamp.org/index.php?topic=43789.msg490584#msg490584
    ;; Polar Stretch Dynamic Parameter Property Names:
    (setq dpn "Distance1" ;; Distance Name
    )
    (if
        (and
            (setq obj (AT:InsertBlock "BLOCKNAME_HERE" (getpoint "\nPick the Block Insertion Point:") 1 1 0))
            (= "AcDbBlockReference" (vla-get-objectname obj))
            (= :vlax-true (vla-get-isdynamicblock obj))
            (setq ins (trans (vlax-get obj 'insertionpoint) 0 1))
            (setq dsp (getpoint ins "\nSpecify New Stretch Distance & Angle: "))
			
			(if (and (> 4.71238898 (angle ins dsp))(< 1.57079633 (angle ins dsp)))
                    (LM:toggleflipstate obj)
                );if
        )
        (foreach prop (vlax-invoke obj 'getdynamicblockproperties)
            (setq prn (strcase (vla-get-propertyname prop)))
            (cond
                (   (= prn (strcase dpn))
                    (vla-put-value prop (vlax-make-variant (distance ins dsp)))
                )
            )
        )
					
        (princ "\nInvalid response or selected object is not a Dynamic Block.")
    )
    (princ)
)
(vl-load-com) (princ)

 

 

Message 11 of 12

I've almost got it, but it seems to be doing something really wierd to the dynamic block. It doesn't show in the dynamic block definition.

 

11-7-2013 10-37-43 AM.png

Message 12 of 12

The wierd behavior is because it does not like the leader. If it is made a polyline it will work correctly.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost