Jump to content

Vla-GetInterfaceObject what is this?


guitarguy1685

Recommended Posts

This is the code i'm currently working with to create an MleaderStyle

 

;; original code by VVA
(defun Create_MleaderStyle	(mleaderstylename
			 MldScale
			 /
			; acaddoc
			; mldrdict
			; newldrstyle
			 ;objcolor
			)
 (vl-load-com)
 (setq acadobj		(vlax-get-acad-object)
acaddoc		(vla-get-activedocument acadobj)
mldrdict	(vla-item (vla-get-dictionaries acaddoc) "ACAD_MLEADERSTYLE")
 ) ;_ end of setq
 (setq	newldrstyle (vlax-invoke-method  mldrdict 'addobject mleaderstylename "AcDbMLeaderStyle"
 ) ;_ end of vlax-invoke-method

 ) ;_ end of setq
 (setq	objcolor (vla-getinterfaceobject acadobj (strcat "AutoCAD.AcCmColor." (substr (getvar "acadver") 1 2)) ;_ end of strcat
	   ) ;_ end of vla-getinterfaceobject       [b][color="red"];;what is vla-getinerfaceobject, and what am i retreiving?[/color][/b]
) ;_ end of setq
 (vla-put-colorindex objcolor 2)
 (vla-put-textcolor newldrstyle objcolor)      [color="red"][b];;howcome I have to set color this way instead of the alternate in code below[/b][/color]
 (vla-put-colorindex objcolor 0)
 (vla-put-leaderlinecolor newldrstyle objcolor)


 (foreach item
   (list
     
     '("AlignSpace" 0.18)
     '("Annotative" 0)
     '("ArrowSize" 0.125)
     ;'("ArrowSymbol" "")
     '("BitFlags" 0)
     ;'("Block" "")
     '("BlockConnectionType" 0)
     '("BlockRotation" 0.0)
     '("BlockScale" 1.0)
     '("BreakSize" 0.125)
     '("ContentType" 2)		;mtext
     '("Description" "")
     '("DoglegLength" 0.125)
     '("DrawLeaderOrderType" 0)
     '("DrawMLeaderOrderType" 1)
     '("EnableBlockRotation" -1)
     '("EnableBlockScale" -1)
     '("EnableDogleg" -1)
     '("EnableFrameText" 0)
     '("EnableLanding" -1)
     '("FirstSegmentAngleConstraint" 0)
     '("LandingGap" 0.09)
     '("LeaderLineType" 1)
     '("LeaderLineTypeId" "ByBlock")
     '("LeaderLineWeight" -2)
     '("MaxLeaderSegmentsPoints" 0)
     (list "ScaleFactor" MldScale)
     '("SecondSegmentAngleConstraint" 0)
     '("TextAlignmentType" 0)
     '("TextAngleType" 0)
     '("TextAttachmentDirection" 0)
     '("TextBottomAttachmentType" 0)
     '("TextHeight" 0.09375)
     '("TextLeftAttachmentType" 1) 
     '("TextRightAttachmentType" 1)
     '("TextString" "")
     '("TextStyle" "StyleName")			;need to add check for existing
     '("TextTopAttachmentType" 0)
   ) ;_ end of list

   (vlax-put newldrstyle (car item) (cadr item))
 ) ;_ end of foreach
 newldrstyle
) ;_ end of defun

 

How come this wont wont? I've tried it, it wont work.

 

(vlax-put-property (vlax-get-property newldrstyle 'Textcolor) 'ColorIndex 5)

Link to comment
Share on other sites

Have a look at "acadver" it returns a different number for every version of Autocad etc Sometimes when opening the Autocad database you have to use the correct number with a version. For this reason I have some code that checks which version is running before opening the, in my case CIV3D database.

 

((vl-string-search "R20.0" vrsn)(setq appstr "10.4"));;2015
((vl-string-search "R20.1" vrsn)(setq appstr "10.5"));;2016     
((vl-string-search "R21.0" vrsn)(setq appstr "11.0"));;2017   

Link to comment
Share on other sites

Yes, i get that part

 

So the line evaluates like this essentially.

 

(setq objcolor (vla-getinterfaceobject acadobj "AutoCAD.AcCmColor.21") )

 

This gives me this

 

objcolor = '#<VLA-OBJECT IAcadAcCmColor 000001607b35b8b0>

 

What is this? Is this a color? Which object does this color belong to? It's used here like this

 (vla-put-colorindex objcolor 2)
 (vla-put-textcolor newldrstyle objcolor)      
 (vla-put-colorindex objcolor 0)
 (vla-put-leaderlinecolor newldrstyle objcolor)

 

Why cant I just do this

 

(vlax-put-property (vlax-get-property newldrstyle 'Textcolor) 'ColorIndex 5)

Link to comment
Share on other sites

Use the vlax-dump-object and look at what comes out it may help to work out whats going on, the styles can rely on a different levels being changed rather than going further down the tree stucture. I did find something that pointed to where you may be able to do direct I will have to do again.

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