Jump to content

VBA line drawing


jakebullet70

Recommended Posts

Its me again... :) (aCad 2007)

 

I am trying to use VBA to draw a line with a text block and am looking for the best way to do that.

 

I am using:

 

Dim obj As AcadLine
Set obj = ThisDrawing.ModelSpace.AddLine(vPoint1, vPoint2)

And this does in fact draw a line. But if you look at the image I have uploaded. The line needs to resemble the top line, the one that is high lighted with the arrows and has the text block on top. So I guess the question is:

 

How do I get the arrows?

Or can I save the existing line and text block (they can be moved around together) and just reload that? That seems like a good idea but I have not figured how to save it.

 

Or am I missing the boat again?

Again, thanks.

dimChair.jpg

Link to comment
Share on other sites

(defun c:dimarr (/ ent entname entguts pt1 pt2 ang revang objtype)
 (setvar "cmdecho" 0)
 (setq layname nil)
 (setq ent T)
 (while ent
   (setq ent   (entsel)
  entname (car ent)
  entguts (entget entname)
  objtype (cdr (assoc 0 entguts))
   )
   (if (= objtype "LINE")
     (progn (setq pt1    (cdr (assoc 10 entguts))
    pt2    (cdr (assoc 11 entguts))
    ang    (angle pt1 pt2)
    revang  (angle pt2 pt1)
    sf    (getvar "dimscale")
    clay    (getvar "clayer")
    entguts (subst (cons 8 clay)
     (assoc 8 entguts)
     entguts
     )
     )
     (entmod entguts)
     (command "-insert" "arrow" pt1 sf sf (r->d revang))
     (setq entname (entlast)
    entguts (entget entname)
    entguts (subst (cons 8 clay)
     (assoc 8 entguts)
     entguts
     )
     )
     (entmod entguts)
     (command "-insert" "arrow" pt2 sf sf (r->d ang))
     (setq entname (entlast)
    entguts (entget entname)
    entguts (subst (cons 8 clay)
     (assoc 8 entguts)
     entguts
     )
     )
     (entmod entguts)
     )
     (command "explode" ent "")
   )
 )
 (setvar "cmdecho" 1)
 (princ)
)

Link to comment
Share on other sites

Sorry, I got tossed a different set of tasks for the week. Hope to re-visit this again next week before I forget everything I have learned about Acad in the last few weeks.

Link to comment
Share on other sites

Well, of course... they changed the specs on me. hehehe. Anyway. I have been given a drawing to insert now. I can use my VBA code and insert it and have added a text block so I can put the text I need

 

What I am trying to do now is resize the left and right sides. I know the total length so that is not a problem I have included the drawing.

 

Any help would be appreciated!

 

Thanks a bunch guys and gals!!!

ChairDim.dwg

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