HELP WITH LISP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I wrote a visual lisp file where I can move an entire block using handles and i'm having several issues. First there's a step where i "ssget x" all the objects in one layer and it's not grabbing the all the objects (module and two rails) after the dynamic block is exploded. It only grabs the object that is a block (the module which i assume that is why it is grabbing it).
another issue is, in the visibility state dynamic block i created a associative dimension where it measure the distance between the roof (i added a noplot line in the block to associate the dimension as a substitute for the roof) I easily just move the block and place the noplot line over the roof because it will not move. only thing that is moving is the module with the two rails. In my code, I wrote that the module will move from this point to another point. in the code I had to explode the block but some reason it just create a duplicate and of the block and then explodes, so I wrote a code step where it will vla-erase the block and have only the exploded block but that loses the associated dimension from the module to the roof. Help please. Im having difficulties. If someone needs more info, I'm glad to provide. Here is the code below:
(defun c:snapRR ()
(vl-load-com)
(setq blocks (vla-get-Blocks(vla-get-ActiveDocument (vlax-get-acad-object))))
(setq myrail(handent "2f2a93"))
(setq myrail2(vlax-ename->vla-object myrail)) ;converts the rail w/ module block to visual lisp properties
(setq myattach(handent "307c0"))
(setq myattach2(vlax-ename->vla-object myattach));converts the attachment block
(vla-explode myattach2)
(vla-erase myattach2)
(vla-explode myrail2)
(vla-erase myrail2)
(setq stptline(ssget "x" '((8 . "noplotr"))));selects all the object in layer noplotr
(setq stptentityname(ssname stptline 0));provides the entity name
(setq stptLINE2(vlax-ename->vla-object stptentityname));converts the object in noplotr to visual lisp prop
(setq startpoint(vla-get-startpoint stptLINE2));retrieves the startpoint of the line in layer noplotr from the property list
(setq stptconvert2(vlax-safearray->list (vlax-variant-value startpoint)));converts the variant to a list
(setq stptconvert3(vlax-3d-point stptconvert2));converts the list of number to 3d point coordinates
(setq attachcoor(ssget "x" '((8 . "noplotA"))));selects all the object in layer noplotA
(setq attachcoor1(ssname attachcoor 0));provides the entity name for the noplotA selection set
(setq attachcoor2(vlax-ename->vla-object attachcoor1));converts the object in layer noplotA to visual lisp prop
(setq getcoor(vla-get-coordinates attachcoor2));grabs the coordinates from the property list
(setq getcoor1(vlax-safearray->list (vlax-variant-value getcoor)));converts variant to list
(setq getcoor2(vlax-3d-point getcoor1));converts the list to a 3d coordinates for movements of blocks
(setq railparts(ssget "x" '((8 . "rails"))));it should select everything in this layer. It only selects the module and not the rails.
(setq railmove(ssname railparts 0));grabs the entity name.
(setq rails(vlax-ename->vla-object railmove));converts it to a visual lisp
(vla-move rails stptconvert3 getcoor2);suppose to move everything in layer "rails" from point stptconvert3 to getcoor2 but it only moves the modules and not rails.; updates any fields based on the movemeent of the rails )
(princ)
)