Jump to content

LM:insertwithstate


rog1n

Recommended Posts

Hi,

always when I search about a question I found rotines write by Lee Mac hehehe. I trying to insert a dynamic block with preset visibility so I used the code below








( LM:insertwithstate ( blk vis  bse cmd def ent ext new obj pth rtn tmp )
    ( pth (   ( blk)) 
          ext ( (( blk)) ())
          bse ( blk)
    )
    ( (  pth)
        ( pth ( pth ))
    )
    (
        (   (
                (
                    (
                        (  bse)
                        ( blk bse)
                    )
                    ( blk ( ( pth bse ext)))
                )
            )
            ( (  bse ))
        )
        (   (
                ( obj
                    (
                        ( (LM:acdoc)
                            ( ( 1 ( 'cvport))
                                'paperspace
                                'modelspace
                            )
                        )
                        'insertblock
                        '(0.0 0.0 0.0)
                        blk
                        1.0 1.0 1.0 0.0
                    )
                )
                ( obj )
                (  ( obj))
            )
            ( obj)
            ( (  bse ))
        )
        (   ( (LM:setvisibilitystate obj vis))
            ( obj)
            (
                (
                    
                    bse
                    
                    vis
                    
                )
            )
        )
        (   ( tmp 0)
            (
                ( 
                    ( blk
                        (  ( ( tmp ( tmp))))
                    )
                )
            )
            (
                (
                    ( (LM:acdoc) 'copyobjects ( obj)
                        ( def
                            (
                                ( (LM:acdoc))
                                'add
                                '(0.0 0.0 0.0)
                                blk
                            )
                        )
                    )
                )
                
            )
            ( obj)
            ( ent ()
                  cmd ( 'cmdecho)
            )
            ( 'cmdecho 0)
            ( )
            (
                (
                    (  blk  1.0  0.0 )
                    ( ( ent ( ent ())))
                    ( new ( ent))
                    (  ( new))
                )
                (
                    ( rtn ( ( new 'explode)))
                    ( new)
                )
            )
            ( 'cmdecho cmd)
            ( ' ( def))
        )
    )
    rtn
)






( LM:getvisibilityparametername ( blk  vis )  
    (
        (
            ( blk 'effectivename)
            ( blk
                (
                    ( ( blk))
                    ( blk)
                )
            )
            (  ( blk))
            (  ( blk))
            ( vis
                (
                   '( ( pair )
                        (
                            (
                                ( 360 ( pair))
                                ( 
                                    ( ( 0 ( ( pair))))
                                )
                            )
                            ( pair)
                        )
                    )
                    (
                        ( ( blk))
                        
                    )
                )
            )
        )
        ( ( 301 ( vis)))
    )
)







( LM:SetVisibilityState ( blk val  vis )
    (
        (
            ( vis (LM:getvisibilityparametername blk))
            (
                ( val)
                ( ' (LM:getdynpropallowedvalues blk vis))
            )
        )
        (LM:setdynpropvalue blk vis val)
    )
)




( LM:acdoc 
    (
        ( ' 'LM:acdoc '
            ( ())
        )
    )
    (LM:acdoc)
)
() ()

 

 

But I found a strange result, on Autocad 2018 when I insert a block the scale of block is set to: Scale X: 0.001, Scale Y: 0.001 and Scale Z: 0.001, but on Autocad Civil 3D 2018 the Scale are 1, anyone know why this happens?

 

I attached a example of block this happens

test.dwg

Link to comment
Share on other sites

That code looks to be seriously mutilated...

 

Original posts here, here & here.

 

As for your question, check the insertion units in your drawings.

Edited by Lee Mac
  • Like 1
Link to comment
Share on other sites

On 5/21/2020 at 3:57 PM, Lee Mac said:

That code looks to be seriously mutilated...

 

Original posts here, here & here.

 

As for your question, check the insertion units in your drawings.

 

Thank you for you reply Lee, I got the exactly code from the first link (maybe my CTRL+C>CTRL+V to the forum bug the code).

 

All drawing units are in meters. you can check below. 

Autocad 2018

 

image.png.8ca0d56c1b01babe8b51120404633efe.pngimage.png.a70d0212e3fa3e47d552fdb706178592.png 

 

Autocad Civil 3D 2018

 

image.png.ee5977160790b22951272dbe81481ff9.pngimage.png.20c81a7b847e4d2943391ceba7d4ad8f.png

 

 

edit: I found the problem on my Autocad 2018 the variable INSUNITSDEFTARGET was set to 4, thank you again Lee.

Edited by rog1n
Link to comment
Share on other sites

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