Jump to content

Recommended Posts

Posted

Hello,
With the help of AI I am trying to make a .lsp script that insert specific block on every vertex of a polyline and orient two "arrows" to the previous and next vertex.
I try with different AI models and always I end up with error in Autocad (I use Autocad 2022) Error: "ActiveX Server returned the error: unknown name: "DYNAMICBLOCKPROPERTIES".
AI say that the block is not really a dynamic block, which I dont get, how block can be not really dynamic.

I am attaching both block and .lsp script. I hope someone will give me some advice what is wrong with the block or with .lsp script.
 

BlockInsert.lsp block.dwg

Posted

Maybe it's just that property doesn't exist on the specified object.

Posted (edited)

For a client did draw arrows I used a entmake pline so have control over the arrow sizes length and width. Its a case of setting the start as 0.0 and a length and an end arrow width. Yes matching angle of a pline and same layer.

 

Can you provide more information about how the arrows are to be shown at each vertice, length and width plus direction.

 

 

image.png.7556470a60fb9f543cfbdfc381834070.png

Edited by BIGAL
Posted

Hello thank you for your reply. 

May be I did not explain properly what I want to do. I will post some pictures may be they will help.

On the Block_1.jpg is how the drawing has to look like.

On the Block_2.jpg is the block it self when is edited.

 

So the script has to change "Angle" and "Angle1" so the so called arrows point to the previous and next block - Block_3.jpg

Block_2.jpg

Block_1.jpg

Block_3.jpg

Posted

Ok thats is very similar to what I was talking about, its easy to draw an arrow at a point along a pline, you can do this in a number of ways one of the easiest is to just use "V" rotated + - to to the angle between the points.

 

Which of these is correct ? You should post a dwg not an image, can then see sizes and offsets from vertices.

 

image.png.2d09261ead41015cf957bf4adf5daead.png

  • Like 1
Posted

I'd be forgetting AI for now, handy for snippets but still not quiet there.

 

Lee Mac has some great resources: 

https://lee-mac.com/dynamicblockfunctions.html

might be what you are looking for.

Also search this forum for Massoc Implementations which can be used to return a list of vertices.

 

 

(defun mAssoc ( key lst / result )
 (foreach x lst
   (if (= key (car x))
     (setq result (cons (cdr x) result))
   )
 )
 (reverse result)
)

 

Will give a list of points along a polyline where key in this case is 10, and list is the polyline entity description from maybe (entget (car (entsel)))

 

 

Dynamic blocks:

(defun LM:getvisibilitystate ( blk / vis )
    (if (setq vis (LM:getvisibilityparametername blk))
        (LM:getdynpropvalue blk vis)
    )
)
(lm:getdynprops (vlax-ename->vla-object (car(entsel))) )

 

returns the format and names of dynamic block variables and setting them with:

 

(defun LM:setdynprops ( blk lst / itm )
    (setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cdr x))) lst))
    (foreach x (vlax-invoke blk 'getdynamicblockproperties)
        (if (setq itm (assoc (strcase (vla-get-propertyname x)) lst))
            (vla-put-value x (vlax-make-variant (cdr itm) (vlax-variant-type (vla-get-value x))))
        )
    )
)
(lm:setdynprops (vlax-ename->vla-object (car(entsel))) (list (cons "Angle" 0) (cons "Angle2" pi)))

 

 

Inserting the blocks can be as simple as (command "insert" "Stylb_NN_nov" -Point- "" "" "")

where point is the points along the massoc returned list (ignore the 1st and last point)

and then use (entlast) in the setdynprops line instead of (car(entsel))

 

 

 

Might be a pointer to get you making something up.

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