Jump to content

Routine to set location of Ordinate Dimension Text...


Recommended Posts

Posted

Hey guys,

 

Just wondering if someone can please help me get the following code working?

 

(DEFUN C:fRD ()
(prompt "\n Select DIMENSIONS to fix offset...")
(Setq ss (ssget '((0 . "DIMENSION") (-4 . "<OR") (70 . 38) (70 . 102) (70 . 166) (-4 . "OR>"))))

(setq gpt1 (getpoint))
 
 (setq num (sslength ss));n° object
 (setq con 0)
 (repeat num  
 (setq ent3A (ssname ss con))
 (setq con (1+ con))

(setq vObje (vlax-ename->vla-object ent3a))
             (vlax-put-property vObje '[color="red"][b]TEXTPOSITIONY[/b][/color] (CADR GPT1))
           )


(princ)
)

 

The aim is to be able to select a bunch of ordinate dims, and then pick a point and the Y value of this new point will be assigned to the "Text Position Y" of the ordinate dimensions selected... I hope that makes sense.

 

The problem I am having is I do not know the correct variable name for TEXTPOSITIONY, so I was wondering if someone could please enlighten me? Or if someone knows of a resource where all the Active X variables are listed - that would also be great.

 

Thanks a lot for any help, looking forward to hearing back.

 

OrdDimTextPos.jpg

Posted

Replace this part .

 

(vlax-put-property vObje 'TEXTPOSITION (vlax-3d-point (list (car (cdr (assoc 14 (entget ent3A)))) (cadr gpt1))))

 

Get the habit of localizing variable to avoid interventions between values - variables .

Posted

Ah awesome, thanks so much for that Tharwat. Yes, it is a bad habit of mine not to localise the variables, I will do it though haha.

 

Thanks again for the help.

Posted
Ah awesome, thanks so much for that Tharwat. Yes, it is a bad habit of mine not to localise the variables, I will do it though haha.

 

Thanks again for the help.

 

You're welcome and I am happy to help :)

Posted

Hi again Tharwat,

 

After a bit more testing, I have got the code working exactly how I wanted it - so thanks again for your help.

 

(DEFUN C:fRD ( / ss gpt1 num con ent3A vObje )
(command "ucs" "W")
(prompt "\n Select DIMENSIONS to fix offset...")
(if (Setq ss (ssget '((0 . "DIMENSION") (-4 . "<OR") (70 . 38) (70 . 102) (70 . 166) (70 . 230) (-4 . "OR>"))))
(progn
(setq gpt1 (getpoint))
 
 (setq num (sslength ss));n° object
 (setq con 0)
 (repeat num  
 (setq ent3A (ssname ss con))
 (setq con (1+ con))

(setq vObje (vlax-ename->vla-object ent3a))
             (vlax-put-property vObje 'TEXTPOSITION (vlax-3d-point (list (car (cdr ([color="red"]assoc 11[/color] (entget ent3A)))) (cadr gpt1))))
           )
)
)
(command "ucs" "p")
(princ)
)

 

A change I made was to use ASSOC with DXF Code 11 - as this seemed to produce better results regarding the base points of the text. Does that sound right to you?

Posted

Using the dump option on an object oftens reveals the variable name you were after, often a slight difference from what is displayed in properties.

 

; TextMovement = 2

; TextOutsideAlign = 0

; TextOverride = ""

; TextPosition = (351.838 301.785 0.0)

; TextPrefix = ""

; TextRotation = 0.0

; TextStyle = "ISO2.5"

 

 

;;; Dump all methods and properties for selected objects              ;
;;;===================================================================; 
;;; DumpIt                                                            ; 
;;;-------------------------------------------------------------------; 
;;;===================================================================; 
(defun C:DumpIt ( / ent) 
 (while (setq ent (entsel)) 
   (vlax-Dump-Object 
     (vlax-Ename->Vla-Object (car ent)) 
   ) 
 ) 
 (princ) 
)

Posted
Hi again Tharwat,

 

After a bit more testing, I have got the code working exactly how I wanted it - so thanks again for your help.

 

A change I made was to use ASSOC with DXF Code 11 - as this seemed to produce better results regarding the base points of the text. Does that sound right to you?

 

You're welcome .

 

Yes , to confirm between my approach and yours , have a look HERE.

Using the dump option on an object oftens reveals the variable name you were after, often a slight difference from what is displayed in properties.

 

;;; Dump all [color=red]methods[/color] and properties for selected objects              ;
;;;===================================================================; 
;;; DumpIt                                                            ; 
;;;-------------------------------------------------------------------; 
;;;===================================================================; 
(defun C:DumpIt ( / ent) 
 (while (setq ent (entsel)) 
   (vlax-Dump-Object 
     (vlax-Ename->Vla-Object (car ent)) 
   ) 
 ) 
 (princ) 
)

 

BIGAL , to have the methods as well , you should add the T to vlax-dump-object funtion . see HERE.

Posted

Thanks Tharwat patched the version I copied from and added T for future use.

Posted

Awesome, thanks for the help Tharwat and BigAl.

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