Jump to content

Move Dynamic Text Property


Ohnoto

Recommended Posts

I'm trying to get some blocks with text in them to move perpendicular to a line selected by the user, so that the text is lined up properly.

 

Attached is the code that I am using and a sample dwg. I can select the block and the line, but then nothing happens. Since the parameter in the block is a point, it is wanting an X and Y value, which is where I think the issue lies.

EXALU_Main - 0001.LSP

Fiber Marker Test.dwg

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • Ohnoto

    16

  • pBe

    11

  • resullins

    1

Top Posters In This Topic

Posted Images

These are dynamic blocks with a move parameter on them, but there are around 30 of these blocks used. I draw a reference line where I want text to be lined up at, and what I'm trying to do is get text of these blocks to move to that line without having to move each one individually, as that can be a bit time consuming.

Link to comment
Share on other sites

These are dynamic blocks with a move parameter on them, but there are around 30 of these blocks used. I draw a reference line where I want text to be lined up at, and what I'm trying to do is get text of these blocks to move to that line without having to move each one individually, as that can be a bit time consuming.

 

Try this:

Only thing is the reference is not a line but one the Dynamic block.

 

 
(defunc:AlgnDyn (/ adoc a baseX BaseXBlock MoveXVal MoveXBlock)
 ;;  pbe Apr2011  ;; 
(vl-load-com)
 (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
 (setq a (car (entsel "\nSelect Reference Dynamic Block:")))
 (setq baseX
    (variant-value
      (vla-get-value
        (nth
          15
          (vlax-invoke
            (vlax-ename->vla-object a)
            'GetDynamicBlockProperties
            )
          )
        )
      )
   BaseXBlock
    (car (cdr (assoc 10 (entget a))))
   )
 (setq MoveXBlock
    (mapcar
      '(lambda (j) (car (cdr (assoc 10 (entget j)))))
      (vl-remove-if
        'listp
        (mapcar
          'cadr
          (ssnamex (ssget ":L" '((0 . "INSERT") (66 . 1))))
          )
        )
      )
   )
 (vlax-for
    Dblks (vla-get-activeselectionset adoc)
   (setq MoveXVal
      (car
        (vlax-safearray->list
          (variant-value (vla-get-insertionpoint Dblks))
          )
        )
     )
   (vla-put-value
     (nth 15 (vlax-invoke Dblks 'GetDynamicBlockProperties))
     (+ (- BaseXBlock MoveXVal) baseX)
     )
   )
 (princ)
 )

 

Usage:

command: AlgnDyn

Select Reference Dynamic Block:

Select objects:

 

This code is written to work specifically on your block (fiber marker tube-sta)

 

Hope this helps

after.jpg

before.jpg

Link to comment
Share on other sites

Thanks, this is a start. I'm curious about two things.

 

1. For accounting for all the blocks we use, I use the following code:

 

(setq blocks (mapcar (function strcase)
       '("anchor-sta"
       "catch basin-sta"
       "conc. pole-sta"
       "elec transformer-sta"
       "fiber marker tube-sta"
       "fire hydrant-sta"
       "grate inlet-sta"
       "handhole-sta"
       "handhole prop-sta"
       "mailbox-sta"
       "manhole-sta"
       "parking meter-sta"
       "pole-sta"
       "property pin-sta"
       "sign-sta"
       "steel pole-sta"
       "steel post-sta"
       "street light-sta"
       "tel ped-sta"
       "test pit-sta"
       "traffic control box-sta"
       "traffic pole-sta"
       "traffic signal-sta"
       "tree-sta"
       "verizon mh-sta"
       "valve-sta"
       "water meter-sta")))

Where would this go at to account for all of these blocks, and not necessarily be based on the fiber block, but any block?

 

 

2. If the viewport of our pages are at any angle other than 0, it aligns the text to an angle. I'm assuming this means there needs to be a trans in the code, but I don't know much about the trans function right now.

Edited by Ohnoto
Link to comment
Share on other sites

Thanks, this is a start. I'm curious about two things.

 

2. If the viewport of our pages are at any angle other than 0, it aligns the text to an angle. I'm assuming this means there needs to be a trans in the code, but I don't know much about the trans function right now.

 

Whoa. i wasnt counting on that, good catch Ohnoto.

 

As for question nos. 1, if you meant text position you can modify the code to search for PropertyName instead of nth 15 (Stationing MoveX) as shown on the code. thats why i've said its specific for this block only where the 15th (actually 16) are the same for all block with the same name.

 

Now for the trans, i need to get back to you on that, its almost quiting time.

i would probably rewrite the code altogether so it would work not only for X postion by Y as well.

 

I'm pretty sure someone here will beat me to it.

:lol:

Link to comment
Share on other sites

 

If the viewport of our pages are at any angle other than 0, it aligns the text to an angle. I'm assuming this means there needs to be a trans in the code, but I don't know much about the trans function right now.

 

 

Are the blocks itslef rotated?

Link to comment
Share on other sites

The block itself is rotated upon insertion. After that the text (stationing) is turned on and there is a rotate parameter for rotating the text, typically at 90 degrees of the current viewport scale, so that the text is written up the page, and read from the right. Hope that answers the question...

Link to comment
Share on other sites

The block itself is rotated upon insertion. After that the text (stationing) is turned on and there is a rotate parameter for rotating the text, typically at 90 degrees of the current viewport scale, so that the text is written up the page, and read from the right. Hope that answers the question...

 

Can you post a drawing file with your rotated blocks

Link to comment
Share on other sites

It's the same what is in the first posting, but here is a drawing. If this isn't what you are wanting, can you give me a bit more detail of what you are looking for exactly?

Fiber Marker Test 2.dwg

Edited by Ohnoto
Link to comment
Share on other sites

It's the same what is in the first posting, but here is a drawing. If this isn't what you are wanting, can you give me a bit more detail of what you are looking for exactly?

 

 

Geez, this is more complicated that i thought i would be. :o thee are too many variables to consider.

 

I was thinking of just X and Y alignment, wasnt considering rotation parameter at all, anyhoo, we'll still give it a shot. (this might require a lot of math)

 

On your sample drawing. how would you like those two to align?

Link to comment
Share on other sites

For the text, how they are shown, straight down from the insertion point of the block for the angle, Then aligned from the move parameter as they are shown now. This is also why I was thinking it might be easier, LISP wise, if those moved to the nearest-point on a line. Our procedure is that we draw a horizontal line and line up our text based off that line, then remove that reference line.

Link to comment
Share on other sites

Any luck getting this figured out?

 

Ohnoto,

 

I havent spent time on your request lately, the thought of writing a code involving too much math throiws me off :lol:. like i've said, too many variables, i.e. rotation parameter, block rotation, current ucs, current view.. though i got a couple of ideas on how to approach this.

 

Anyhoo, what have you got so far?

Link to comment
Share on other sites

Ohnoto,

 

I havent spent time on your request lately, the thought of writing a code involving too much math throiws me off :lol:. like i've said, too many variables, i.e. rotation parameter, block rotation, current ucs, current view.. though i got a couple of ideas on how to approach this.

 

Anyhoo, what have you got so far?

 

As for rotation, the code I have is, but it has the same issue as the line up parameter in that if it isn't inserted at 0, the block rotation isn't put at 90 degrees of the viewport angle.

 

(defun RotateStationing ()
 
 (setq staBlockName (mapcar (function strcase)                            ; Lists blocks to be adjusted.
                         '("as-built-sta"
               "anchor-sta"
               "catch basin-sta"
               "conc. pole-sta"
               "elec transformer-sta"
               "fiber marker tube-sta"
               "fire hydrant-sta"
               "grate inlet-sta"
               "handhole-sta"
               "handhole prop-sta"
               "mailbox-sta"
               "manhole-sta"
               "parking meter-sta"
               "pole-sta"
               "property pin-sta"
               "sign-sta"
               "steel pole-sta"
               "steel post-sta"
               "street light-sta"
               "tel ped-sta"
               "test pit-sta"
               "traffic control box-sta"
               "traffic pole-sta"
               "traffic signal-sta"
               "tree-sta"
               "verizon mh-sta"
               "valve-sta"
               "water meter-sta"
               )))
 
 (setq vwPort (+ (- (getvar "viewtwist")) (/ pi 2)))                        ; Sets text angle to 90 degrees of the current viewport.
 (if (setq ss (ssget                                              ; Without "_X", allows user to select which blocks to adjust
                     (list '(0 . "INSERT")
                           (cons 2
                                 (apply (function strcat)
                                        (cons "`*U*,"
                                              (mapcar (function (lambda (s) (strcat s ",")))
                                                      staBlockName)))))))
        (progn
     (vlax-for x (setq ss (vla-get-activeselectionset
                            (cond (*ACADdoc*)
                                  ((setq *ACADdoc* (vla-get-activeviewport
                                                     (vlax-get-acad-object)))))))
       (if (and (vl-position
                  (strcase (vlax-get-property
                             x
                             (if (vlax-property-available-p x 'EffectiveName)
                               'EffectiveName
                               'Name)))
                  staBlockName)
                (eq (vla-get-isDynamicBlock x) :vlax-true))
         (vl-some (function (lambda (p)
                              (if (eq (vlax-get-property p "PropertyName") "Stationing Angle")
                                (not (vl-catch-all-error-p
                                       (vl-catch-all-apply
                                         (function vlax-put-property)
                                         (list p "Value" vwPort)))))))                ; Assigns value of the viewport angle to the property
                  (vlax-invoke x 'GetDynamicBlockProperties))))
     (vla-delete ss)))
 (princ)
)

As for the UCS, I would think there may be something that could be done through the viewtwist system variable and not necessarily the UCS. Currently, I am also not experienced enough with LISP to even begin to figure out those other variable issues like block angle mixed with the stationing angle, but I am trying.

Edited by Ohnoto
Link to comment
Share on other sites

  • 4 weeks later...

pBe.. or anyone else,

 

To eliminate all those variable issues, I've realized that the best thing to do is not specify rotation on insertion, which means all blocks will be placed at the rotation of 0, since we don't mess with the UCS at all, just viewtwist on pages.

 

I editted the coding in the previous posting slightly, but it does works in regards to that it puts all the text at the proper angle based on the viewport twist. Now my only question would be getting these lined up based on selecting a line. I realize that the original coding was created with the premise of lining up the text based on that specific block, but I'd really like it to be based on selecting a line since we have various blocks on each page and not any specific one on a page.

Link to comment
Share on other sites

oh that... tell me again what you need done with this?

 

this time give us a graphic presentation of at least 3 conditions you need the routine to aligned

 

:)

Link to comment
Share on other sites

What I am trying to do is get text that is embedded within my dynamic blocks with a move parameter to line up based on a user selected line. The dynamic parameter is called "Stationing Move"

 

The block list is:

(setq blocks
  '(
     "ANCHOR-STA" 
     "CATCH BASIN-STA" 
     "CONC. POLE-STA" 
     "ELEC TRANSFORMER-STA"
     "EXPRESS NOTES-STA"
     "EXPRESS BOLD NOTES-STA"
     "FIBER MARKER TUBE-STA" 
     "FIRE HYDRANT-STA" 
     "GRATE INLET-STA" 
     "HANDHOLE-STA" 
     "HANDHOLE PROP-STA" 
     "MAILBOX-STA" 
     "MANHOLE-STA" 
     "PARKING METER-STA" 
     "POLE-STA" 
     "PROPERTY PIN-STA" 
     "SIGN-STA"
     "STEEL POLE-STA" 
     "STEEL POST-STA" 
     "STREET LIGHT-STA" 
     "TEL PED-STA" 
     "TEST PIT-STA" 
     "TRAFFIC CONTROL BOX-STA" 
     "TRAFFIC POLE-STA" 
     "TRAFFIC SIGNAL-STA" 
     "TREE-STA" 
     "VERIZON MH-STA" 
     "VALVE-STA"
     "VIEWPORTLINE"
     "WATER METER-STA"
   )
 )

Here is an image:

LineUpText-1.jpg

Edited by Ohnoto
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...