Jump to content

Recommended Posts

Posted (edited)

Hello all,

 

A coworker and I have been attempting to enhance a batch plot program that prints autocad blocks. Currently we have a lisp routine that asks the user to manually select a block (the border) and from that we grab it's location & scale setting to set other variables for the drawing including the limits based off of the insertion point location of the border. We use the limits in the batch plot to know what window to print, that way even if there is geometry outside of someones border, it will only print what is inside of it.

 

What we are attempting to do is have the batch plot program (written in VB6) to pick the border when it opens the drawing to plot it. Therefore the drafter will not have to remember to read the border manually.

 

Our problem is this: We can find that the border block exists in a drawing. We've found code that will allow us to delete that block, explode it etc, but nothing that will simply let us "pick" it programmatically.

 

Does anybody have an example of this if it is even possible. Or do you have any other ideas?

 

If it helps any, here is the lisp we use to manually get the border information:

(Defun Setx (/ os a b c d e l)
   (Setvar "Cmdecho" 0)
   (Setq os (Getvar "Osmode"))
   (Setvar "Osmode" 0)
   (Setq a (Entsel "\nSelect Block:"))
   (While (Not a)
    (Prompt "\nYou Missed... Try Again")
    (Setq a (Entsel "\n  Select Block:"))
   )
   (Setq b (Entget (Car a)))
   (Setq c (Cdr (Assoc 42 b)))
   (Setq d (Cdr (Assoc 10 b)))
   (Setq e (Mapcar '+ (Mapcar '(Lambda (x) (* x c)) '(32 20)) d))
   (Setvar "Dimscale" c)
   (Setvar "Textsize" (* 0.125 c))
   (Setvar "Ltscale" (/ c 4))
   (Command ".Setvar" "Limmin" d)
   (Command ".Setvar" "Limmax" e)
   (Setvar "Cmdecho" 1)
   (Command ".Line" d e "")
   (Command "Delay" "5")
   (Setq l (Ssget "X" (List (Cons 0 "Line") (Cons 10 d))))
   (Command ".Erase" l "")
   (Setvar "Osmode" os)
   (Prompt "\n ")
   (Print (Getvar "Dimscale"))
   (Prompt " is now the Current Dimscale.")
   (Prompt "\nLimits were Set as Shown.")
   (Princ)
)(PRINC)

 

 

Thank you for your feedback!

MBS

Edited by Tiger
added codetags
Posted

try ssget with the block and block name filter

Posted

Not sure if it is a clean way to do it, but we discovered that when we have the vb start the lisp routine, we can tell it to "Select" and "Last" after we've read the attributes in the border, and it picks the border. Now on to testing to clean out a couple other little bugs, but if somebody else has a cleaner way, it would still be appreciated. Or if you have any other comments, I'd like to hear them too.

 

We played around with ssget but couldn't figure out how to make it work for us.

 

Thanks,

MBS

Posted

With regards to the single selection, this may work better for you: allowing you to select more than one object (and any object - not just a block):

 

(defun setx ( / ss bb ) (vl-load-com)

 (if (and (setq ss (ssget))
          (setq bb (LM:SSBoundingBox ss)))
   
   (vla-AddLine
     (vlax-get-property
       (vla-get-ActiveDocument
         (vlax-get-acad-object)
       )
       (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace)
     )
     (vlax-3D-point (car bb)) (vlax-3D-point (cadr bb))
   )
 )

 (princ)
)


(defun LM:SSBoundingBox ( ss / bb ) (vl-load-com)
 ;; © Lee Mac 2010
 (
   (lambda ( i / e ll ur )       
      (while (setq e (ssname ss (setq i (1+ i))))
        (vla-getBoundingBox (vlax-ename->vla-object e) 'll 'ur)

        (setq bb (cons (vlax-safearray->list ur)
                       (cons (vlax-safearray->list ll) bb))
        )
      )
    )
   -1
 )

 (mapcar
   (function
     (lambda ( fun )
       (apply (function mapcar) (cons fun bb))
     )
   )
   '(min max)
 )
)

Of course, it just draws a line to demonstrate the limits, you could use vla-SetWindowtoPlot, then vla-PlottoDevice if you wanted to plot using LISP.

Posted

BTW to answer your original question:

 

(ssget "_X" '((0 . "INSERT") (2 . "[color=red]YourBlockNameHere[/color]")))

Posted

Awesome. Thanks for the help. I will let you know how it ends up.

 

MBS

Posted

heres sample code in vba looks for blocks called Dwg1drgtxt which are our title blocks in multiple layouts

 

Dim SS As AcadSelectionSet
Dim Count As Integer
Dim FilterDXFCode(1) As Integer
Dim FilterDXFVal(1) As Variant
Dim attribs As Variant

On Error Resume Next
FilterDXFCode(0) = 0
FilterDXFVal(0) = "INSERT"
FilterDXFCode(1) = 2
FilterDXFVal(1) = "DA1DRTXT"

Set SS = ThisDrawing.SelectionSets.Add("issued")
SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal

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