Author Topic: Embarrassingly Befuddled  (Read 3025 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Guest
Embarrassingly Befuddled
« on: November 17, 2005, 11:08:38 AM »
Hey all.
I am finally breaking down. 
I have been avoiding the swamp for a while, drained beyond comprehension.   :cry:
I am embarrassed to ask 'cause I prefer to learn, but under the circumstances, I don't know what else to do.    :oops:
So, I'm going to ask.
Could someone PLEASE write a lisp for me that will put a wipeout box around a dimension on an associative string that becomes part of the entity.?.
Much like the textmask for a dtext and mtext, it becomes a part of the entity.
And then, could you integrate into the first, a second lisp that will delete the wipeout box from the entity without exploding or altering the entity in any way.?.
Like the textunmask command from the express tools.

I have tried several types of examples, VL, and even the swamp.  I've asked several people for some ideas and help, but because of my schedule and workload, sometimes it's days before I can return to post something.  Anyway, everything I've tried has failed miserably and I don't know VL enough to make anything work.

Thank you.

Bob Wahr

  • Guest
Re: Embarrassingly Befuddled
« Reply #1 on: November 17, 2005, 11:37:24 AM »
I can't do this for you in lisp, sorry, but it seems the easiest way to go about it would be to place a wipeout around the text portion, and make a group from the dimension and the wipeout.  Throwing a reactor in so that the wipeout updates when the text changes is even better.

LE

  • Guest
Re: Embarrassingly Befuddled
« Reply #2 on: November 17, 2005, 11:44:59 AM »
Why you do not hire a professional to do, what you are looking for?

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Embarrassingly Befuddled
« Reply #3 on: November 18, 2005, 08:14:08 AM »
Quote
Could someone PLEASE write a lisp for me that will put a wipeout box around a dimension on an associative string that becomes part of the entity.?.

It's not that I wouldn't do it because I believe it would be a worth while application for everyones use. But what you're asking for is lot of work for me, assuming I could write such an application, and I just don't have the time to invest in it right now. Even the professional programmers here would have to spend many hours on such an application. /guess

Quote
Why you do not hire a professional to do, what you are looking for?
There ya go!! Problem solved. :-)
TheSwamp.org  (serving the CAD community since 2003)

Hangman

  • Guest
Re: Embarrassingly Befuddled
« Reply #4 on: November 18, 2005, 11:28:38 AM »
Hey guys, thanks for your input.
Quote
... it seems the easiest way to go about it would be to place a wipeout around the text portion, and make a group from the dimension and the wipeout.  Throwing a reactor in so that the wipeout updates when the text changes is even better.
Bob, I appreciate your idea, my problem is, I don't know how to do that.
I've been trying to make the following code work, but every time I edit it, it no longer works.  Then again, I don't know just what I'm doing to make it work correctly.  This code will put a box around an associative dimension, making it a part of the entity, but I don't know how to make it a wipeout box.
Code: [Select]
(setvar "cmdecho" 1)
(vl-load-com)
(prompt "\nEntity-Box Loaded... Start with Command: < txtbx >"
) ;_ end of prompt
;;;---DIMENSION--- 
(defun msk-dim ()
  (setq dim-gap
    (vlax-make-variant
      (* -0.5 (vla-get-textgap vla-ename-ent))
       vlax-vbString
    ) ;_ end of vlax-make-variant
  ) ;_ end of setq
  (vla-put-textgap vla-ename-ent dim-gap)
) ;_ end of defun
;;;---TEXT---
(defun msk-txt (/ p0 p1 p2 p3 p4 t1 t2 sinrot cosrot list1 list2 margin ang)
  (setq e-list (entget ename-ent))
  (setq p0 (cdr (assoc 10 e-list))
        ang (cdr (assoc 50 e-list))
        margin (* 0.425 (cdr (assoc 40 e-list)))
        list1  (list (- margin) (- margin) 0.0)
        list2  (list margin margin 0.0)
        sinrot (sin ang)
        cosrot (cos ang)
        t1 (mapcar '+ (car (textbox e-list)) list1)
        t2 (mapcar '+ (cadr (textbox e-list)) list2)
        p1 (list
             (+ (car p0) (- (* (car t1) cosrot) (* (cadr t1) sinrot)))
             (+ (cadr p0) (+ (* (car t1) sinrot) (* (cadr t1) cosrot)))
           ) ;_ end of list
        p2 (list
             (+ (car p0) (- (* (car t2) cosrot) (* (cadr t1) sinrot)))
             (+ (cadr p0) (+ (* (car t2) sinrot) (* (cadr t1) cosrot)))
           ) ;_ end of list
        p3 (list
             (+ (car p0) (- (* (car t2) cosrot) (* (cadr t2) sinrot)))
             (+ (cadr p0) (+ (* (car t2) sinrot) (* (cadr t2) cosrot)))
           ) ;_ end of list
        p4 (list
             (+ (car p0) (- (* (car t1) cosrot) (* (cadr t2) sinrot)))
             (+ (cadr p0) (+ (* (car t1) sinrot) (* (cadr t2) cosrot)))
           ) ;_ end of list
  ) ;_ end of setq
  (command "pline" p1 "w" "0" "0" p2 p3 p4 "c")
) ;_ end of defun
;;;---MTEXT---
(defun msk-mtxt (/ minpoint maxpoint t1a t2a list1 list2 margin)
  (vla-GetBoundingBox vla-ename-ent 'minpoint 'maxpoint)
  (setq t1a (vlax-safearray->list minpoint))
  (setq t2a (vlax-safearray->list maxpoint))
  (setq e-list (entget ename-ent))
  (setq margin (* 0.425 (cdr (assoc 40 e-list)))
        list1 (list (- margin) (- margin) 0.0)
        list2 (list margin margin 0.0)
        t1a (mapcar '+ t1a list1)
        t2a (mapcar '+ t2a list2)
  ) ;_ end of setq
  (command ".rectangle" t1a t2a)
) ;_ end of defun

;;;-----------MAIN-------------
(defun c:txtbx ()
  (setvar "cmdecho" 1)
  (setq oldos (getvar "osmode"))
  (setvar "osmode" 0)
  (vl-load-com)
  (initget 1)
  (setq ename-ent (car (entsel "\nPick an Entity:")))
  (if ename-ent
    (progn
      (setq vla-ename-ent (vlax-ename->vla-object ename-ent))
      (cond ((vlax-property-available-p vla-ename-ent "textgap") (msk-dim))
        ((= "AcDbText" (vla-get-objectname vla-ename-ent)) (msk-txt))
        ((= "AcDbMText" (vla-get-objectname vla-ename-ent)) (msk-mtxt))
        (T (alert "Not possible....."))
      ) ;_ end of cond
    ) ;_ end of progn
    (alert "You did not select anything")
  ) ;_ end of if
  (setvar "osmode" oldos)
  (setvar "cmdecho" 1)
  (princ)
) ;_ end of defun
I want to take the text and mtext box creation out, I don't need it.  But I've tried everything I can think of and everything I can find in my dismal amount of time I can't get it to work after I start editing it.

LE asked:
Quote
Why you do not hire a professional to do, what you are looking for?
Then what is the purpose of the Swamp?  I was to the understanding that we come here to talk about code, to learn and to grow.  Perhaps I mis-spoke myself, I am very interested in learning the code.  I don't post here often because I would prefer to learn it rather than have you good people doing things for me.  I come here to get ideas and to give ideas when I can, but I try to make the code work before I post a question and ask for help.  I have searched high and low, through ALL of the archives here and ALL of the archives from Cadalyst's Get-the-Code to try and find something that will give me an idea of how to make a wipeout around a dimension string.  I haven't found anything.  I have struggled for weeks, going through the VL help files from Autodesk to Nemi's Pacifier, but I'm missing something, or more than just a something & I don't know what it is.  I don't know how to put reactors together.  I don't know what sequence is needed get a file, create something, replace something and release the file with VL.

Look, I love writing code.  If I knew enough to be effective, I'd give fish out all day.  But the truth of the matter is, I've got to learn to fish before I can give it out.

Mark stated:
Quote
It's not that I wouldn't do it because I believe it would be a worth while application for everyones use. But what you're asking for is lot of work for me, assuming I could write such an application, and I just don't have the time to invest in it right now. Even the professional programmers here would have to spend many hours on such an application. /guess
Thank you Mark, I appreciate your comment and concern.  I understand your time and everyone elses time is important.  And your mentioning of taking many hours to write such a code shows my lack of understanding of the task.  Perhaps there is my first mistake, I am thinking it would not take very long to do.  But then, I put together little projects like callout marks and hold-down symbols which, I have gotten quite resourceful at & it doesn't take me very long to put those together any more.

I have a wipeout mask created for bubble cuts, shear wall callouts and footing callouts.  But I don't know how to extract the text gap box of an attribute block or the dimension string to create a simple wipeout box for the text at some angle.
I was hoping that if someone could throw together a program that would do this (a wipeout box integrated into a dimension string), I would be able to take that example and expand upon it to create a similar thing for attributed blocks and other text as well.

LE

  • Guest
Re: Embarrassingly Befuddled
« Reply #5 on: November 18, 2005, 12:31:10 PM »
LE asked:
Then what is the purpose of the Swamp?  I was to the understanding that we come here to talk about code, to learn and to grow. 

I was referring to a last resort, nothing else.

Dimensions are [re-drawn and becomes an new entity] every time they are modified, what you are trying to do is something many had tried, without success, it is time to move into C++ and ObjectARX.

Have fun.

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Embarrassingly Befuddled
« Reply #6 on: November 18, 2005, 03:00:12 PM »
Hangman,
IF Autodsek had exposed the Wipeout object to ActiveX this would probably be a fairly simple routine. This particular situation requires adding a wipeout object to a predefined block. Since the only way to add a wipeout is by calling the wipeout command we cannot programmaticly(sp?) create the object, which means you can't use a reactor.....

That being said, here is a primitive method to add the wipeout and another to remove it. It is not "smart", IOW it doesn't update with the text. But you can remove it and remask it pretty quickly.

There are no error checks included and really should be added to make sure correct objects are selected, etc. Feel free to use this as a starting point.
Code: [Select]
(defun c:dimmask
       (/ diment dimobj dimblk txt rotang ll ur rect wipout newdim newrect)
  (vla-startundomark *doc*)
  (setq diment (car (entsel "\nSelect dimension: "))
dimobj (vlax-ename->vla-object diment)
dimblk (vla-item (vla-get-blocks *doc*)
(cdr (assoc 2 (entget diment)))
       )
  )
  (regapp "JMM_DIMMASK")
  (vlax-for x dimblk
    (if (vl-string-search "TEXT" (strcase (vla-get-objectname x)))
      (setq txt x)
    )
  )
  (setq rotang (vla-get-rotation txt))
  (vla-put-rotation txt 0)
  (vla-getboundingbox txt 'll 'ur)
  (setq ll (vlax-safearray->list ll)
ur (vlax-safearray->list ur)
  )
  (vla-put-rotation txt rotang)
  (command "rectangle" ll ur)
  ;;this could be programmed
  (setq rect (vlax-ename->vla-object (entlast)))
  (vlax-invoke
    rect
    'rotate
    (vlax-get txt 'insertionpoint)
    rotang
  )
  (vla-offset
    rect
    (* (vla-get-scalefactor dimobj) (vla-get-textgap dimobj))
  )
  (vla-delete rect)
  (setq newrect (entlast))
  (command "wipeout" "n" newrect "y")
  ;;this cannot be programmed, AFAIK
  (setq wipout (vlax-ename->vla-object (entlast)))
  (setq newdim (vlax-invoke dimobj 'copy))
  (vla-delete dimobj)
  (vlax-invoke newdim 'setxdata (list 1001 1071) (list "JMM_DIMMASK" (vla-get-objectid wipout)))
  ;;tried adding the wipout & newdim to a group,
  ;;but they are not selectable as a group....
  (vla-endundomark *doc*)
  (princ)
)

(defun c:undimmask (/ diment dimobj icode vdata newiCode newvVal)
  (if (and (setq diment (car (entsel "\nSelect dimension: ")))
   (vl-string-search "DIMENSION" (cdr (assoc 0 (entget diment))))
   (setq dimobj (vlax-ename->vla-object diment))
   )
    (progn
      (vla-startundomark *doc*)
      (vlax-invoke-method dimobj 'getxdata "" 'iCode 'vData)
      (setq objID (vlax-variant-value
    (nth (vl-position 1071 (vlax-safearray->list icode)) (vlax-safearray->list vdata))))
      (vla-delete (vla-objectidtoobject *doc* objid))
      (setq newiCode (vlax-make-safearray vlax-vbinteger '(0 . 0)))
      (setq newvVal (vlax-make-safearray vlax-vbVariant '(0 . 0)))
      (vlax-safearray-fill newiCode '(1001))
      (vlax-safearray-fill newvVal '("JMM_DIMMASK"))
      (vla-setxdata dimobj newiCode newvVal)
      (vla-endundomark *doc*)
      )
    )
  (princ)
  )

Hangman

  • Guest
Re: Embarrassingly Befuddled
« Reply #7 on: November 23, 2005, 10:55:24 AM »
Thank you Jeff.  I'll look this over and see what I can't do with it.  And Thank you LE for the input, no wonder I haven't been able to find anything similar.
With my exams, papers, family and work, It may be a month or so before I can get back with you on this issue.  But I do appreciate your help and input.
Thanks again.